[Tutor] Expanding a variable with subprocess on Windows
Becky Mcquilling
ladymcse2000 at gmail.com
Tue Mar 8 07:44:31 CET 2011
I'm working on a Windows machine and want to use subprocess to run several
commands from the command line.
Normally with bat files or some of the other scripting languages on Windows,
I would set up a variable with the path to the command like so:
gpg = 'c:/program files (x86)/gnu/gnupg/gpg2.exe'
Then call the command the variable to avoid typing in the full path.
When I do this with subprocess it works:
subprocess.Popen('c:/program files (x86)/gnu/gnupg/gpg2.exe', shell=True)
However when I do this:
gpg = 'c:/program files (x86)/gnu/gnupg/gpg2.exe'
subprocess.Popen('gpg', shell=True)
It fails to run gpg and is not expanding the variable. Is there a way to do
this that I'm missing?
Becky
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110307/5daf89c0/attachment.html>
More information about the Tutor
mailing list