shell script stdout to python string?

Rick L. Ratzel rick.ratzel at scd.magma-da.com
Thu May 20 15:34:28 EDT 2004


    Check out:

http://www.python.org/doc/current/lib/module-commands.html

    It's Unix-specific, but I guess you did say "Unix command"...


-Rick Ratzel


Jeff Learman wrote:
> 
> Hi -- sorry for not searching first, but I get an NNTP error from 
> netscape (a known bug, still looking for workaround).
> 
> Inside a python script, I want to execute a UNIX command and
> send the output to a Python string, returning the shell return
> code value as an integer or exception.
> 
> I'm sure I could write a function using pipes and whatnot, but
> I'm hoping this is a solved problem by now, more elegantly and
> correctly coded than my hack job would be.
> 
> Thanks,
> Jeff
> 
> Python rocks, btw.  I've almost broken the #!/bin/ksh habit ;)
> 



More information about the Python-list mailing list