How to convert below bash code in perl and python.
Code:for BLOCK in /sys/block/emcpow* do echo "100000" > "$BLOCK"/queue/nr_requests echo "noop" > "$BLOCK"/queue/scheduler done
How to convert below bash code in perl and python.
Code:for BLOCK in /sys/block/emcpow* do echo "100000" > "$BLOCK"/queue/nr_requests echo "noop" > "$BLOCK"/queue/scheduler done
Perl (untested):
Don't know why you'd want to do that though; the bash version makes a lot more sense.Code:for (glob '/sys/block/emcpow*') { open REQ, '>', "$_/queue/nr_requests"; print REQ "100000\n"; close REQ; open SCHED, '>', "$/queue/scheduler"; print SCHED "noop\n"; close SCHED; }
Last edited by trent.josephsen; August 24th, 2012 at 12:26 AM. Reason: forgot newline
I forgot to add a newline to "noop" (edited in my prior post).
If that doesn't fix your problem, well, I don't know why. Do you understand how it works or did you just copy and paste it?
Run it with perl -w at least to enable warnings.
Bookmarks