FAQ
When I use os.popen(cmd,'w'), I find that under windows, the stdout
of the child process disappears, instead of appearing in the DOS window
the script is invoked from. eg:

C:\> type foo.py
import os
import sys
file = os.popen("nslookup", 'w')
file.write("google.com\n")
file.close()

C:\> python foo.py
<-- nothing is printed
C:\>

This just seems wrong. The following DOS equivalent works fine:

C:\> echo google.com | nslookup
Default Server: dns.erco.x
Address: 192.168.1.14
[..expected output..]

When I run the same python program on a unix box, the output
from 'nslookup' appears in the terminal, as I'd expect.

Shouldn't popen() be consistent in its handling of the child's
stdout and stderr across platforms?

Maybe I'm missing something, being somewhat new to python, but
an old hand at unix and win32 and functions like popen(). Didn't
see anything in the docs for popen(), and I googled around quite
a bit on the web and groups for eg. 'python windows popen stdout lost'
and found nothing useful.

FWIW, I'm using the windows version of python 2.5 from activestate.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedMay 12, '07 at 3:46a
activeMay 12, '07 at 4:33a
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase