3
我有一個問題,而運行我的telnet腳本使用pexpect.problem是它只取用戶名從腳本不password.Its採取的密碼的價值,但它不輸入相同。下面提到我的劇本,Python:telnet密碼不是通過腳本使用pexpect
import pexpect
import sys,time
ipaddr = "192.168.100.85"
username = "usr"
password = "[email protected]"
telconn = pexpect.spawn("telnet " + ipaddr)
telconn.expect(":")
telconn.logfile=sys.stdout
time.sleep(15)
telconn.sendline(username + "\r")
telconn.expect(":")
telconn.sendline(password + "\r")
time.sleep(30)
telconn.expect(">")
print "Authentication Sucesss"
輸出的這一點,
Trying 192.168.100.85...
Connected to 192.168.100.85.
Escape character is '^]'.
Welcome to Microsoft Telnet Service
login: usr
password: [email protected]
The operation completed successfully.
Login Failed
+1這也適用於我。感謝abhi。 – 2014-04-16 20:20:05