[Tutor] using variables as args
Jerome Jabson
jjabson at yahoo.com
Mon May 8 22:22:17 CEST 2006
Thank you, Alan! I'll try using POPEN.
Jerome
--- Alan Gauld <alan.gauld at freenet.co.uk> wrote:
> > I'm trying to start a shell script with 4
> arguments
> > from my python script. I'm having problems trying
> to
> > figure out the best way to do this.
>
> Use a format string:
>
> cmd = "myscript %s %s %s %s"
> os.system(cmd % (p1,p2,p3,p4))
>
> OR
>
> cmdstr = cmd % p1,p2,p3,p4
> os.system(cmdstr)
>
> The second form is easier to debug...
>
> > to use popen3 to keep track of stdin, stdout, and
> err,
>
> Ok, substitute popen3 for system().
> Or better still use the subprocess module and
> the Popen class.
>
> See the OS topic in my tutor for more on the
> subprocess
> module.
>
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Tutor
mailing list