popen4

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • billie

    #1

    popen4

    Hi all. I'm trying to execute system commands and capture the output by
    using popen4:

    stdout example:[color=blue][color=green][color=darkred]
    >>>exec_cmd = popen2.popen4(" echo hello!")
    >>>output = exec_cmd[0].read()[/color][/color][/color]
    hello

    stderr example:[color=blue][color=green][color=darkred]
    >>>exec_cmd = popen2.popen4(" echobv hello!")
    >>>output = exec_cmd[0].read()[/color][/color][/color]
    Unrecognized command

    The problem occurs when I try to execute interactive commands like ftp,
    python intepreter etc...
    In this case the program crashes without even giving an error.
    Suggestions?

    Regards


  • Piet van Oostrum

    #2
    Re: popen4

    >>>>> "billie" <mlist@fastwebn et.it> (b) wrote:
    [color=blue]
    >b> Hi all. I'm trying to execute system commands and capture the output by
    >b> using popen4:[/color]
    [color=blue]
    >b> stdout example:[color=green][color=darkred]
    >>>>> exec_cmd = popen2.popen4(" echo hello!")
    >>>>> output = exec_cmd[0].read()[/color][/color]
    >b> hello[/color]
    [color=blue]
    >b> stderr example:[color=green][color=darkred]
    >>>>> exec_cmd = popen2.popen4(" echobv hello!")
    >>>>> output = exec_cmd[0].read()[/color][/color]
    >b> Unrecognized command[/color]
    [color=blue]
    >b> The problem occurs when I try to execute interactive commands like ftp,
    >b> python intepreter etc...
    >b> In this case the program crashes without even giving an error.[/color]

    Crashes?
    [color=blue]
    >b> Suggestions?[/color]

    I think you need something like pyexpect for this.
    --
    Piet van Oostrum <piet@cs.uu.n l>
    URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C 4]
    Private email: piet@vanoostrum .org

    Comment

    • billie

      #3
      Re: popen4


      Piet van Oostrum wrote:[color=blue]
      > I think you need something like pyexpect for this.[/color]

      PyExpect seems to be no more mantained.


      Comment

      • Ganesan Rajagopal

        #4
        Re: popen4

        >>>>> "billie" == billie <mlist@fastwebn et.it> writes:
        [color=blue]
        > Piet van Oostrum wrote:[color=green]
        >> I think you need something like pyexpect for this.[/color][/color]
        [color=blue]
        > PyExpect seems to be no more mantained.[/color]

        Try pexpect instead. http://pexpect.sourceforce.net/

        Ganesan

        --
        Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
        Web: http://employees.org/~rganesan | http://rganesan.blogspot.com

        Comment

        • Ralf Muschall

          #5
          Re: popen4

          Ganesan Rajagopal wrote:
          [color=blue]
          > Try pexpect instead. http://pexpect.sourceforce.net/[/color]
          ^

          That's a content-free ad site. You probably mean sourceforGe.

          Ralf

          Comment

          Working...