[Tutor] how to get response from os.system()

Nathan McBride nomb85 at comcast.net
Sun Mar 16 20:29:29 CET 2008


Why don't you just use 'commands.getoutput'?

-----Original Message-----
From: linuxian iandsd <pylinuxian at gmail.com>
Sent: Sunday, March 16, 2008 3:12 PM
To: tutor at python.org
Subject: Re: [Tutor] how to get response from os.system()

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


[The entire original message is not included]


More information about the Tutor mailing list