本文整理汇总了Python中netmiko.ConnectHandler.write_channel方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectHandler.write_channel方法的具体用法?Python ConnectHandler.write_channel怎么用?Python ConnectHandler.write_channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netmiko.ConnectHandler
的用法示例。
在下文中一共展示了ConnectHandler.write_channel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConnectHandler
# 需要导入模块: from netmiko import ConnectHandler [as 别名]
# 或者: from netmiko.ConnectHandler import write_channel [as 别名]
#!/usr/bin/env python
import time
from netmiko import ConnectHandler, redispatch
net_connect = ConnectHandler(
device_type="terminal_server",
ip="10.10.10.10",
username="admin",
password="admin123",
secret="secret123",
)
# Manually handle interaction in the Terminal Server (fictional example, but
# hopefully you see the pattern)
net_connect.write_channel("\r\n")
time.sleep(1)
net_connect.write_channel("\r\n")
time.sleep(1)
output = net_connect.read_channel()
# Should hopefully see the terminal server prompt
print(output)
# Login to end device from terminal server
net_connect.write_channel("connect 1\r\n")
time.sleep(1)
# Manually handle the Username and Password
max_loops = 10
i = 1
while i <= max_loops:
output = net_connect.read_channel()