Problem with PEXPECT in Python

jai simhan jeyasimhan at gmail.com
Tue Oct 23 08:42:13 EDT 2007


import sys,os
import pexpect

source_file= 'sourcefile.txt'

user='username'

ip='00.00.00.00'
desti_path='/home/jai/………'
password='bond007'





cmd ='scp'+' '+source_file+' '+user+'@'+ip+':'+desti_path

        try:

                foo = pexpect.spawn(cmd)

                foo.expect('.ssword:*')

                foo.sendline(passwd)

                foo.sendline('Passwd_to_server')

                foo.interact()

        except Exception,e:
                pass

Its simple, this should work, it works for me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071023/bfbed332/attachment.html>


More information about the Python-list mailing list