A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/110664.html below:

catching the output of system()

catching the output of system()Praveen Pathiyil praveen.pathiyil at wipro.com
Thu Apr 26 03:06:59 EDT 2001
Hi all,

    I am trying to capture the output written to the stdout during an
os.system() call. ( BTW i am trying to invoke the system tftp through
os.system().)

I was trying out the following way.

               (rd, wr) = os.pipe()
                print rd, wr
                dup_stdout = os.dup(1)
                os.dup2(wr, 1)
                ret = os.system(line)

### line contains the tftp command

                res = os.read(rd, 64)
                os.dup2(1, dup_stdout)
                os.fdopen(1, 'a+')
                print res

But i couldn't get the 'stdout' to revert back to the fd of '1'.

If any one has any ideas on this or any more elegant methods of doing this,
please help me out.

Thanks in advance,
Praveen.


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4