[Tutor] execute an OS command, get the output

Alan Gauld alan.gauld at freenet.co.uk
Sun Mar 12 09:39:58 CET 2006


> Just for the heack of it, I wrote a tiny Python echo program, and 
> interposed it in the pipe between the strings and grep command:
> 
> while 1:
>     line = raw_input()
>     print line
> 
> The command line now looks like this:
> 
>> strings 00003193.DAT | python echo.py | grep Newsgroups: | head -10
> Newsgroups: comp.lang.python.announce
> ...
> Newsgroups: comp.lang.python.announce
> Traceback (most recent call last):
>  File "echo.py", line 3, in ?
>    print line
> IOError: [Errno 22] Invalid argument
> close failed: [Errno 22] Invalid argument

Thats exactly what I ghad in mind! :-)

You've saved me the effort, thanks agin.

Alan G




More information about the Tutor mailing list