output of shell command

David Bolen db3l at fitlinxx.com
Tue Feb 27 20:45:33 EST 2001


"Mark Hadfield" <m.hadfield at niwa.cri.nz> writes:

> "Steve Holden" <sholden at holdenweb.com> wrote in message
> news:pgWm6.169$jv4.27104 at e420r-atl2.usenetserver.com...
> > Dunno. Still won't work for me on Windows 98. Neither, come to that, does
> > the parenthesized version
> >
> >     a=(os.popen("dir")).readlines()
> >
> > I get the same error.
> 
> OK so the parentheses were a red herring. It's a difference in the behaviour
> of piping in windowed applications vs console applications under Windows 9x.

I don't recall if the version of Python was noted in this thread yet,
but there are definite issues and differences with console versus
windowed applications in os.popen with Python 1.5.2, and still some
environmental dependencies with Python 2.x.

In Python 1.5.2, os.popen is a direct call to the underlying C popen()
function, which under Windows requires that there be a console to be
reliable under NT, and may not be reliable at all under Windows 9x.

In Python 2.x (and maybe 1.6), os.popen borrowed code from the
win32all package (which you can also use under Python 1.5.2 as
win32pipe.popen()) which works properly in both console and windowed
environments.  But under Windows 9x, it needs a helper application
(win32popenWin9x.exe under win32all, or w9xpopen.exe under Python 2.x)
to function properly.

It's possible that under Pythonwin, the appropriate utility isn't
being found on your path, which may differ from the path you get in a
command prompt or in other tools.  Python should return a runtime
error describing this file, but perhaps that's being absorbed in
Pythonwin or something.

Just as an experiment you might try placing that file (it's in the
Python 2.0 main directory or the win32 subdirectory with win32all) in
a directory known to be in your main path.

I think Mark Hammond may have posted recently on this issue and
suggested copying the executable into the same directory as
PythonWin.exe - yep, that was the suggestion.  I don't know how to
make a canonical reference to Google's newsgroup stuff yet, but if you
search for "w9xpopen pythonwin" on http://groups.google.com it'll
bring it up.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list