[Tutor] how to get response from os.system()

shawn bright nephish at gmail.com
Mon Mar 17 01:34:25 CET 2008


thanks all, appreciate it much.
shawn

On Sun, Mar 16, 2008 at 6:10 PM, Nathan McBride <nomb85 at comcast.net> wrote:
> Yup I use the pexpect module for a lot however couldn't get 'pexpect.run' to work with mysqldump piping to gzip
>
>
>  -----Original Message-----
>  From: Jeff Younker <jeff at drinktomi.com>
>  Sent: Sunday, March 16, 2008 6:59 PM
>  To: Nathan McBride <nomb85 at comcast.net>
>  Cc: tutor at python.org
>  Subject: Re: [Tutor] how to get response from os.system()
>
>
>
>
> > Would you mind perhaps show an example running an interactive
>  > command like su and show how to send input to the commands waiting
>  > propmts?
>
>  If you're doing that then you *really* want to be using the pexpect
>  module.
>
>  cmd = pexpect.spawn('su - SOMEINTERACTIVECOMMAND')
>  cmd.expect('# ')   # the prompt
>  cmd.sendline('A COMMAND')
>  cmd.expect('# ')   # wait for the prompt again
>  output = cmd.before  # the stuff before the prompt
>  cmd.sendline('exit')
>  cmd.close()
>
>
>  - Jeff Younker - jeff at drinktomi.com -
>
>
>
>  _______________________________________________
>  Tutor maillist  -  Tutor at python.org
>  http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list