Newbie Alert: subprocess.call
Ben Finney
ben+python at benfinney.id.au
Wed May 19 23:28:12 EDT 2010
Patrick Maupin <pmaupin at gmail.com> writes:
> On May 19, 9:27 pm, Carbon <nob... at nospam.tampabay.rr.com> wrote:
> > subprocess.call(["/opt/2X/Client/bin/appserverclient", "-u
> > fieldValues [0]", "-p fieldValues[1]", "-s ts.mycompany.org:80", "-d
> > corp", "-S local", "-c 16", "-e 0xF", "-l 0x0409", "-a #1"])
As Patrick says, you need to give the arguments to the command as
the shell would pass them. That means option arguments separate from
value arguments, etc.
> I think, for example, instead of "-d corp", you want "-d" and "corp"
> in your list.
Right.
> I usually make a string like I would pass to bash, and then do
> .split() on it to get the list. This works fine unless you need
> embedded spaces anywhere.
Better is to use ‘shlex.split’ to split the string as a shell parser
would do <URL:http://docs.python.org/library/shlex#shlex.split>.
--
\ “Not using Microsoft products is like being a non-smoker 40 or |
`\ 50 years ago: You can choose not to smoke, yourself, but it's |
_o__) hard to avoid second-hand smoke.” —Michael Tiemann |
Ben Finney
More information about the Python-list
mailing list