Running any linux command line inside your python script.
1 2 3 4 5 6 7 8 9 10 11 12 | #/usr/bin/env python
import subprocess
class RunCmd(object):
def cmd_run(self, cmd):
self.cmd = cmd
subprocess.call(self.cmd, shell=True)
#Sample usage
a = RunCmd()
a.cmd_run('ls -l')
|
Bad code. Stop writing classes everywhere!
import os os.system("ls -l")
to Andrey, for example do you have in your mind?
well i meant that i can extend this class to deal with stdout stderr with subprocess module and i think this option is not supported by os module.