Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
没有定时器的多个Python telnet写和读命令?_Python_Python 2.7_Timer_Telnet_Telnetlib - Fatal编程技术网

没有定时器的多个Python telnet写和读命令?

没有定时器的多个Python telnet写和读命令?,python,python-2.7,timer,telnet,telnetlib,Python,Python 2.7,Timer,Telnet,Telnetlib,我已经建立了到Telnet的连接,并且正在传递基本命令。我希望避免在每个写入命令之间使用1秒或2秒的计时器,因为我不希望30个写入命令占用一分钟的时间。如果删除“time.sleep”,则无法及时读取下一个命令的输出。有人能帮忙吗?我最终使用了tn.expect,它似乎大大减少了脚本的运行时间。 while True: command = raw_input("=> ") if command == 'Exit': tn.write(command + "\

我已经建立了到Telnet的连接,并且正在传递基本命令。我希望避免在每个写入命令之间使用1秒或2秒的计时器,因为我不希望30个写入命令占用一分钟的时间。如果删除“time.sleep”,则无法及时读取下一个命令的输出。有人能帮忙吗?

我最终使用了tn.expect,它似乎大大减少了脚本的运行时间。
while True:
    command = raw_input("=> ")
    if command == 'Exit':
        tn.write(command + "\r\n")
        time.sleep(1)
        tn.close()
        break
tn.write(command + "\r\n")
time.sleep(2)
print tn.read_very_eager()