popen and password entry
sinan nalkaya
orome.the.valar at gmail.com
Thu Jun 15 08:14:50 EDT 2006
finally following code works,
import pexpect, sys
cmd = '/usr/bin/rsync config root at 10.1.1.2:/tmp/.'
#cmd = 'ssh root at 10.1.1.2'
child = pexpect.spawn(cmd)
child.logfile = sys.stdout
passwd = 'qwe123'
i = 0
try:
while i == 0:
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'
More information about the Python-list
mailing list