开发者

How to submit different scripts to the command line in python -

开发者 https://www.devze.com 2023-03-31 00:44 出处:网络
I\'m trying to loop through and submit shell scripts t开发者_运维百科o the command line in python.While this works for a given file:

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号