[Tutor] how to get response from os.system()
linuxian iandsd
pylinuxian at gmail.com
Sun Mar 16 20:12:51 CET 2008
use os.popen("your cmd here")
On Sun, Mar 16, 2008 at 8:06 PM, Luke Paireepinart <rabidpoobear at gmail.com>
wrote:
> shawn bright wrote:
> > Lo there all,
> >
> > I am needing to get a response back from a system command.
> > i can do this:
> >
> > os.system('mailq | wc -l")
> >
> > if i do this in the terminal mailq | wc -l , it will spit out a
> number.
> > How do i get that number as a python variable ?
> You need to use the subprocess module, specifically subprocess.Popen, to
> open an input pipe from the command so you can read() the data in.
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080316/b82f8ab4/attachment.htm
More information about the Tutor
mailing list