prev | Invoking bash command within python program #How to invoke normal bash commands from python? # For that you need to import a module called os. import os os.system('ls -l') # prints the contents print os.system('ls -l') # prints contents + return code error = os.system('ls -l tmp') #exit code is stored in error if error == 0: print 'found' else: print 'not found' |
next |