Capturing output from stderr

  • Thread starter Doru-Catalin Togea
  • Start date
D

Doru-Catalin Togea

Hi!

On solaris, I call a program from python with

os.system("some command > outputFile.txt" )

This redirects the output of "some command"'s stdout to "outputFile.txt".
However I need to redirect or somehow capture the output from "some
command"'s stderr to this file too. How can I do that?

Thanks,
Catalin
 
K

Klaus Alexander Seistrup

Doru-Catalin Togea said:
On solaris, I call a program from python with

os.system("some command > outputFile.txt" )

This redirects the output of "some command"'s stdout to "outputFile.txt".
However I need to redirect or somehow capture the output from "some
command"'s stderr to this file too. How can I do that?

You could do "some command >outputFile.txt 2>&1", or you could use the
commands.getoutput() or commands.getstatusoutput() methods.

Cheers,
 
D

Doru-Catalin Togea

On Mon, 5 Dec 2005, Doru-Catalin Togea wrote:

Found a solution:

os.system("some command 1>out.txt 2>err.txt")
On solaris, I call a program from python with

os.system("some command > outputFile.txt" )

This redirects the output of "some command"'s stdout to "outputFile.txt".
However I need to redirect or somehow capture the output from "some
command"'s stderr to this file too. How can I do that?

Thanks,
Catalin

--

<<<< ================================== >>>>
<< We are what we repeatedly do. >>
<< Excellence, therefore, is not an act >>
<< but a habit. >>
<<<< ================================== >>>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top