redirecting output

Emile van Sebille emile at fenx.com
Fri Mar 3 14:30:08 CET 2000


Well, that's what I thought, but when I try it on my
non-recently-rebooted win95 I get:

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> os.popen("dir").read()
Traceback (innermost last):
  File "<pyshell#1>", line 1, in ?
    os.popen("dir").read()
OSError: (0, 'Error')
>>>

and I wasn't sure what to make of the error?

I figure rebooting may help, but I don't have 20 minutes
to spare at the moment.  (Don't ask, it's u*g*l*y)

More to the point thought, is how to diagnose this error?
Does the OS just not want to play right now?

Emile van Sebille
emile at fenx.com
-------------------


----- Original Message -----
From: Jesper Hertel <jh at cddk.dk>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Friday, March 03, 2000 2:34 AM
Subject: Re: redirecting output


> Hi Andres,
>
> os.popen(command_line) returns a pipe from wich you can read the
standard
> output from the command given by command_line.
>
> That is, for example,
>
>      a = os.popen("dir").read()
>
> runs the command "dir" and puts the entire output from the command in
the
> variable a.
>
> Another function os.popen2() also returns standard error output from
the
> command, but this does not work in Windows, unfortunately.
>
>
> Jesper Hertel
>
> Andres M. Hidalgo <andres at hidalgo.cnchost.com> wrote in message
> news:89nbc0$2ng at journal.concentric.net...
> > How can I run another application(non .py) from within a .py script
and
> > capture its output  ala perl way, without saving the other apps.
output to
> a
> > file. I'am using python in Windows NT/2K
> > Andres
> >
> >
>
>
> --
> http://www.python.org/mailman/listinfo/python-list
>






More information about the Python-list mailing list