finally following code works,
import pexpect, sys cmd = '/usr/bin/rsync config [EMAIL PROTECTED]:/tmp/.' #cmd = 'ssh [EMAIL PROTECTED]' 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' -- http://mail.python.org/mailman/listinfo/python-list