By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,995 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,995 IT Pros & Developers. It's quick & easy.

shell script stdout to python string?

P: n/a

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

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Check out:

http://www.python.org/doc/current/li...-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 ;)

Jul 18 '05 #2

P: n/a
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/li...-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 ;)


Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.