Access stdout from external program.

Paul Lemelle pdl5000 at yahoo.com
Fri Jul 30 12:19:32 EDT 2010


JM,

Thanks for the response.  

I am trying to capture the stdout of a program from another program. Example, I want to launch the below program from a second python script then capture the first's program stdout to a file or variable. 

Is this possible?

Thanks again,
Paul




Paul Lemelle wrote:
> HELP! :)
>
> I am trying to output the following program's output to either a file
> or variable, how can this be done?
>
> # Writing the output to a standard argv argument
>
> #1/usr/bin/python
>
> import sys
>
> for arg in sys.argv:
>   print arg
>
> #END
>
> Thanks,
> Paul
>
>
Hi Paul, after reading 4 times your post, I still don't see what you
want to achieve.
What are you calling a variable ? an os variable ?

import sys

file = open('testfile.txt', 'w')
file.write(str(sys.argv))
file.close()

second hit when googling your question:
http://docs.python.org/tutorial/inputoutput.html

JM



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100730/0f9fe904/attachment.html>


More information about the Python-list mailing list