
Используя телнет подключаюсь к железке, где необходимо в завимисимости от выводимой строки в дальнейшем подавать команды. Подобный код работать отказывается:
import telnetlib, sys host = '192.168.1.1' telnet (host) def telnet(h): print ('Enter User Name:') user = input() print ('Enter Password') password = input() tel=telnetlib.Telnet(h,23,2) tel.set_debuglevel(10) tel.read_until(b"Name\r\n>",2) write(user.encode('ascii')+b"\r\n") read_until(b"Password\r\n>",2) write(password.encode('ascii')+b"\r\n") after_logging=tel.read_eager() var1=str.encode('Condition 1') var2=str.encode('Condition 2') if after_logging.find(another_user_logged_in) is True: print('Something in first condition') tel.close elif after_logging.find(another_user_logged_in) is True: print('Something in second condition') tel.close else: print('Something wrong')
Совершенно очевидно, что ошибка скрыта в моём понимании if else цикла и .find команды. Уважаемые, прошу подсказать, как всё же правильно отслеживать то, что выводится в консоль?