python - Python 初学者 - SSH 和用户输入问题
问题描述
我得到了一个脚本,它允许我登录到设备,然后将输出转储到文本文件中。这太棒了。我需要能够为多个设备执行此操作。所以我想做的是这个。我运行脚本,它要求我输入 IP。我输入 IP,它登录然后将输出转储到文件中,但我似乎无法将输入传递给脚本的其余部分。
另外快速请求是如果有人可以指导我但不要为我解决问题,这样我可以更好地学习。谢谢你。
from netmiko import ConnectHandler
ipaddr = input('Type IP:')
device(I've tried net_connect also) = ConnectHandler(ip = 'ipaddr',
port = 22,
username = 'admin',
password = 'mypassword',
device_type = 'cisco_wlc_ssh')
net_connect.find_prompt()
'(Cisco Controller) >'
output = net_connect.send_command('show ap summary')
print(output)
net_connect.disconnect()
解决方案
推荐阅读
- python-3.x - Python3 - 在标题之前从 CSV 中删除前几行
- perl - 使用“perl -pi -e”修补二进制文件在 mac os mojave 中无法按预期工作
- java - 实施 GDPR 时 MainActivity 出错
- html - 我无法在我的网页上禁用 scroll-x,我已经尝试了一切
- javascript - 使用动态表时如何根据下拉列表使用jquery显示/隐藏列?
- java - 了解累加器的归约操作 - java 8
- sql - 如何在 SQL 中选择有关联的记录?
- javascript - 如何将幻灯片与滑动器滑块对齐?
- javascript - 如何将参数从功能组件传递到类组件
- python - 继承类的顺序在 Python 中很重要吗?