shell script stdout to python string?

Jeff Learman jlearman at cisco.com
Thu May 20 17:25:45 EDT 2004


Thanks!  Just what I was looking for ... don't know why I didn't
see it in the docs.

Rick L. Ratzel wrote:

> 
>    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