Capturing output from stderr

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doru-Catalin Togea

    #1

    Capturing output from stderr

    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


  • Klaus Alexander Seistrup

    #2
    Re: Capturing output from stderr

    Doru-Catalin Togea wrote:
    [color=blue]
    > 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?[/color]

    You could do "some command >outputFile.t xt 2>&1", or you could use the
    commands.getout put() or commands.getsta tusoutput() methods.

    Cheers,

    --
    Klaus Alexander Seistrup
    Magnetic Ink, Copenhagen, Denmark
    A small ActivityPub server for friends of Magnetic Ink.

    Comment

    • Doru-Catalin Togea

      #3
      Re: Capturing output from stderr

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

      Found a solution:

      os.system("some command 1>out.txt 2>err.txt")
      [color=blue]
      > 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
      >
      >
      >[/color]

      --

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

      Comment

      Working...