thanks all, appreciate it much. shawn
On Sun, Mar 16, 2008 at 6:10 PM, Nathan McBride <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> > Sent: Sunday, March 16, 2008 6:59 PM > To: Nathan McBride <[EMAIL PROTECTED]> > Cc: tutor@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 - [EMAIL PROTECTED] - > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor