Hi Tim,
> I now realize that to properly test this, I should use a command that
> returns legitimate data:
> I think the following gets me started:
> f = os.popen('ls *.py','r').read()
> now I have captured the output from 'ls *.py'.
You probably should consider using the Popen class in the new
Hi Tim,
Yes, you're on the right track.
a,b,c = os.popen3('wt *.py','r')
res = a.read()
The error you're getting has nothing to do with the result of the
command, but check, from the docs:
popen3( cmd[, mode[, bufsize]])
Executes cmd as a sub-process. Returns the file objects (child_s
Hey Hugo:
I now realize that to properly test this, I should use a command that
returns legitimate data:
I think the following gets me started:
f = os.popen('ls *.py','r').read()
now I have captured the output from 'ls *.py'.
So, if I do this with popen3:
>>> a,b,c = os.popen3('wt *.py','r')
>>>
I also noticed that if you want to get the manpage, you will be hurt by
the interactivity of 'man' (it uses less for paging) One way to get the
whole manpage as text without paging is to do:
man -P /bin/cat
So you won't have to do strange stuff in stdin to get it to give you the
whole text.
H
Hi Tim,
You are correctly using the filehandles you have, but the man command
must be sending the response into STDERR instead of STDOUT. This makes
sense, since it is an error message.
Take a look at popen4() and popen3() which both let you catch the
standard error of a process. Also, in mor
Hi:
I've got a question about popen2.
Consider the following code: (on linux)
import popen2
fin, fout = popen2.popen2("man nothere")
## interpreter outputs the following:
No manual entry for nothere
The following queries of the returned file objects
give the following:
>>> fin
', mode 'r' at 0x4