How to submit different scripts to the command line in python -
I'm trying to loop through and submit shell scripts t开发者_运维百科o the command line in python. While this works for a given file:
os.system('qsub /directory/filename')
This does not:
file = '/directory/filename'
os.system('qsub file')
Python is interpreting the word 'file' instead of the object file. How can I get around this?
Try this:
file = '/directory/filename'
os.system('qsub %s' % file)
You have to pass 'file' as an argument.
See http://diveintopython.net/native_data_types/formatting_strings.html for some examples or http://docs.python.org/library/stdtypes.html#string-formatting for the official docs.
'qsub file' is a string use 'qsub ' + file
Use:
os.system('qsub %s' % file)
精彩评论