Popen Question

Mark Wooding mdw at distorted.org.uk
Mon Nov 8 04:43:27 EST 2010


Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> writes:

> In message <ib0kor015nt at news5.newsguy.com>, Chris Torek wrote:
>
> >     ['/bin/sh', '-c', 'echo', '$MYVAR']
> > 
> > (with arguments expressed as a Python list).  /bin/sh takes the
> > string after '-c' as a command, and the remaining argument(s) if
> > any are assigned to positional parameters ($0, $1, etc).
>
> Doesn’t work.

What doesn't work?  You were being given an explanation, not a solution.

> I don’t know what happens to the extra arguments, but they just seem
> to be ignored if -c is specified.

The argument to -c is taken as a shell script; the remaining arguments
are made available as positional parameters to the script as usual (only
starting with $0 rather than $1, for some unknown reason).

-- [mdw]



More information about the Python-list mailing list