By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

passing a variable to an external program

P: n/a
I want to run an external program using os.system() but I want to
include a variable in the middle of the command line.

An example of the type of thing I want to be able to do:
pathname = os.path.dirname(sys.argv[0])
os.system('cscript /nologo ' + pathname + '\test.vbs')

When I run this, everything after pathname + seems to be ignored. Is
this just incorrect syntax or am I trying to do something fundamentally
wrong? Is there a better way to do something like this? I'm trying to
move from perl to python and this is my first attempt at python.

Jan 11 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 2007-01-11, Rich <ri*******@gmail.comwrote:
I want to run an external program using os.system() but I want to
include a variable in the middle of the command line.

An example of the type of thing I want to be able to do:
pathname = os.path.dirname(sys.argv[0])
os.system('cscript /nologo ' + pathname + '\test.vbs')
Use / instead of \, or \\ instead of \.

--
Neil Cerutti
Ushers will eat latecomers. --Church Bulletin Blooper
Jan 11 '07 #2

P: n/a
Thank you, that did it. I don't know why I didn't think to escape the
\ with \\.

On Jan 11, 2:18 pm, Neil Cerutti <horp...@yahoo.comwrote:
On 2007-01-11, Rich <richfa...@gmail.comwrote:
I want to run an external program using os.system() but I want to
include a variable in the middle of the command line.
An example of the type of thing I want to be able to do:
pathname = os.path.dirname(sys.argv[0])
os.system('cscript /nologo ' + pathname + '\test.vbs')Use / instead of \, or \\ instead of \.

--
Neil Cerutti
Ushers will eat latecomers. --Church Bulletin Blooper
Jan 11 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.