我一直在尝试编写一个代码,允许我从telnet服务器获取一个文件,我想知道是否可以在telnet write函数中包含变量。在
这是我的密码。在
import telnetlib
import sys
import getpass
host = "192.168.1.1"
tn = telnetlib.Telnet(host, "23")
tn.write((" \n").encode('ascii'))
tn.write((" \n").encode('ascii'))
tn.write(("terminal length 1000 \n").encode('ascii'))
tn.write(("terminal width 24 \n").encode('ascii'))
tn.write(("""copy command-output "show tech all" tftp 192.168.1.10 test.txt \n""").encode('ascii'))
tn.write(("exit \n").encode('ascii'))
tn.write(("exit \n").encode('ascii'))
tn.write(("y").encode('ascii'))
print (tn.read_all())
这是正在发送的命令,它应该在一个字符串中。在
复制命令输出“show tech all”tftp 192.168.1.10测试.txt在
而不是测试.txt我想去主机.txt在
例如在上面的代码host==192.168.1.1中,那么实际上文件名应该是192.168.1.1.txt,这可能吗?在
目前没有回答
相关问题 更多 >
编程相关推荐