Redirecting system output quietly

StvB mesteve_bpleaseremovethis at hotmail.com
Mon Nov 15 21:36:39 EST 2004


cmdline = 'whatever command you want to run'
pipe = os.popen(cmdline + " 2>&1")
     for line in pipe.readlines():
            tempList.append(line)
        rc = pipe.close()
        if rc:
           ErrorResult = 1
        else:
           fg.ErrorResult = 0



"Eddie Parker" <eddie at replicon.com> wrote in message 
news:mailman.6395.1100563802.5135.python-list at python.org...
> Look at the 'popen' modules.
>
> (I believe their under the os module).
>
> -e-
>
> -----Original Message-----
> From: python-list-bounces+eddie=replicon.com at python.org
> [mailto:python-list-bounces+eddie=replicon.com at python.org] On Behalf Of
> Madhusudhanan Chandrasekaran
> Sent: November 15, 2004 5:03 PM
> To: python-list at python.org
> Subject: Redirecting system output quietly
>
> Hi,
>  I am a newbie here. I want to know how to redirect os.system("ls -af")
> to a string variable without it barfing the answer of ls -af on the
> screen.
>
> Thanks in advance,
> Madhusudhanan.C
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.788 / Virus Database: 533 - Release Date: 01/11/2004
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.788 / Virus Database: 533 - Release Date: 01/11/2004
>
>
> 





More information about the Python-list mailing list