Python网络设备。。一般查询:
这是有效的: 我曾经为思科供应商编写设备驱动程序。。 我通过Telnet设备IP使用putty登录到那个里的设备,它进入设备并使用脚本中的一些命令获取信息。。像我的脚本中的show version命令n get一样,我将所有信息读取到CSV文件中 以下问题的解决方案 现在,我们有了一家名为北电的新供应商。。当我使用putty中的IP时,它会进入设备,完成菜单或键盘驱动Python网络设备。。一般查询:,python,networking,network-programming,cisco-ios,Python,Networking,Network Programming,Cisco Ios,这是有效的: 我曾经为思科供应商编写设备驱动程序。。 我通过Telnet设备IP使用putty登录到那个里的设备,它进入设备并使用脚本中的一些命令获取信息。。像我的脚本中的show version命令n get一样,我将所有信息读取到CSV文件中 以下问题的解决方案 现在,我们有了一家名为北电的新供应商。。当我使用putty中的IP时,它会进入设备,完成菜单或键盘驱动 它要求按Ctrl-y继续,并使用箭头键列出“硬件信息”等选项,我需要选择n enter以获取信息 如何编写脚本以进入完全由key
import pexpect
child = pexpect.spawn ('ftp ftp.openbsd.org')
child.expect ('Name .*: ')
child.sendline ('anonymous')
child.expect ('Password:')
child.sendline ('noah@example.com')
child.expect ('ftp> ')
child.sendline ('ls /pub/OpenBSD/')
child.expect ('ftp> ')
print child.before # Print the result of the ls command.
child.interact() # Give control of the child to the user.
您只需查找control等键的特殊控制代码。使用。它是一个python模块,设计用于与本地或远程进程交互。下面是其网站上的一个示例,展示了如何使用它连接到键盘驱动的FTP子进程
import pexpect
child = pexpect.spawn ('ftp ftp.openbsd.org')
child.expect ('Name .*: ')
child.sendline ('anonymous')
child.expect ('Password:')
child.sendline ('noah@example.com')
child.expect ('ftp> ')
child.sendline ('ls /pub/OpenBSD/')
child.expect ('ftp> ')
print child.before # Print the result of the ls command.
child.interact() # Give control of the child to the user.
您所需要的只是查找特殊的控制代码,例如控制键。毫无疑问,您需要在标题中添加“常规查询”的位置在这里是合适的。提出具体问题,提供参考资料,展示努力。阅读常见问题解答。在这里,没有问题需要在标题中添加“常规查询”。提出具体问题,提供参考资料,展示努力。阅读常见问题。