Translation of Shell Script in to Python -



Translation of Shell Script in to Python -

i want write python code run job of next shell script me:

for run in {1..100} /home/example.r done

the shell script running r script 100 times. since new python can help me write code in python?

you can utilize python's commands module execute external commands , capture output. module has function commands.getstatusoutput(cmd), cmd command looking run, string.

something trick:

import commands x in xrange(100): commands.getstatusoutput("/home/example.r")

each iteration of loop, commands.getstatusoutput() function homecoming tuple (status, output), status status after executing program, , output beingness command have written stdout.

hope helps.

python shell

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -