How do I capture the output of os.system()

Discussion in 'Python' started by Frank Teoh, Oct 22, 2004.

  1. Frank Teoh

    Frank Teoh Guest

    I am trying to capture the output of os.system() into a string without
    success. Since os.system() returns only its exit_status, how can I do
    that?
    system(...)
    system(command) -> exit_status

    Execute the command (a string) in a subshell.

    My aim is to capture the return value of os.system("rsh
    <netapp_filer_host> qtree")

    Thanks.
    -FT
     
    Frank Teoh, Oct 22, 2004
    #1
    1. Advertising

  2. Frank Teoh

    Gandalf Guest

    You should better use os.popen. Please see the documentation of popen in
    the os module:

    http://www.python.org/doc/2.3.4/lib/os-newstreams.html#l2h-1380

    Frank Teoh wrote:

    >I am trying to capture the output of os.system() into a string without
    >success. Since os.system() returns only its exit_status, how can I do
    >that?
    >system(...)
    > system(command) -> exit_status
    >
    > Execute the command (a string) in a subshell.
    >
    >My aim is to capture the return value of os.system("rsh
    ><netapp_filer_host> qtree")
    >
    >Thanks.
    >-FT
    >
    >
     
    Gandalf, Oct 22, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yingqi Tang
    Replies:
    2
    Views:
    93
  2. Wes Gamble
    Replies:
    2
    Views:
    102
    Robert Klemme
    Jun 19, 2009
  3. Pea
    Replies:
    4
    Views:
    89
    J├╝rgen Exner
    Jan 29, 2004
  4. Replies:
    5
    Views:
    162
    Big and Blue
    Jun 20, 2005
  5. Replies:
    8
    Views:
    168
Loading...

Share This Page