hi,
i have found expect method for this purpose. i`m trying to use pexpect but following code gives me an something strange as a result.
# The CODE
import pexpect
cmd = '/usr/bin/rsync config [EMAIL PROTECTED]:/tmp/.'
#cmd = 'ssh [EMAIL PROTECTED]'
child = pexpect.spawn(cmd)
passwd = 'qwe123'
try:
        i = child.expect(['Password:','Password: ',pexpect.EOF,pexpect.TIMEOUT])
        if i == 0:      child.sendline(passwd)
        elif i == 1:    print 1
        elif i == 2:    print 2
        elif i == 3:    print 3
except EOF:     print 'EOF'
except TIMEOUT: print 'TIMEOUT'
print 'finished'

# The result
finished
Exception pexpect.ExceptionPexpect: <pexpect.ExceptionPexpect instance at 0xb7dfab2c> in <bound method spawn.__del__ of <pexpect.spawn instance at 0xb7db3a2c>> ignored

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to