[Python] python实现的telnet客户端程序 →→→→→进入此内容的聊天室

来自 , 2021-03-26, 写在 Python, 查看 137 次.
URL http://www.code666.cn/view/bee3d073
  1. import getpass
  2. import sys
  3. import telnetlib
  4.  
  5. HOST = "hostname"
  6.  
  7. user = raw_input("Enter your remote account: ")
  8.  
  9. password = getpass.getpass()
  10.  
  11. tn = telnetlib.Telnet(HOST)
  12.  
  13. tn.read_until("login: ")
  14.  
  15. tn.write(user + "\n")
  16.  
  17. if password:
  18.     tn.read_until("Password: ")
  19.     tn.write(password + "\n")
  20.  
  21. tn.write("ls\n")
  22.  
  23. tn.write("exit\n")
  24.  
  25. print tn.read_all()
  26. #//python/8412

回复 "python实现的telnet客户端程序"

这儿你可以回复上面这条便签

captcha