Best command for running shell command
Thomas Nelson
thn at mail.utexas.edu
Tue Jul 11 09:53:44 EDT 2006
Yes, I highly recommend the subprocess module. subprocess.call() can
do almost anything you want to do, and the options are all pretty
intuitive Whenever I need to write quick scripts for myself, it's what
I use.
THN
Roy Smith wrote:
> In article <0001HW.C0D95C2600E03045F0284530 at News.Individual.DE>,
> Donald Duck <bluejump at mac.com> wrote:
>
> > I'm a little bit confused about what is the best way to run a shell command,
> > if I want to run a command like
> >
> > xxxxxx -a -b > yyyyyy
> >
> > where I'm not interested in the output, I only want to make sure that the
> > command was executed OK. How should I invoke this (in a Unix/linux
> > environment)?
>
> The most straight-forward way would be:
>
> import os
> status = os.system ("xxxxxx -a -b > yyyyyy")
> if status == 0:
> print "it worked"
> else:
> print "it failed"
>
> You might also want to look at the new (in 2.4) subprocess module.
More information about the Python-list
mailing list