저는 파이썬의 telnetlib을 사용하여 일부 컴퓨터에 텔넷하고 몇 가지 명령을 실행하고 있는데,이 명령의 출력을 얻고 싶습니다.실시간으로 telnetlib로 출력 읽기
따라서, 현재의 시나리오는 무엇인가 - 이제
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("command1")
tn.write("command2")
tn.write("command3")
tn.write("command4")
tn.write("exit\n")
sess_op = tn.read_all()
print sess_op
#here I get the whole output
, 내가 sess_op에있는 모든 통합 된 출력을 얻을 수 있습니다.
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("command1")
#here I want to get the output for command1
tn.write("command2")
#here I want to get the output for command2
tn.write("command3")
tn.write("command4")
tn.write("exit\n")
sess_op = tn.read_all()
print sess_op
내 경우에는 작동하지 않습니다. – theharshest