【发布时间】:2018-03-04 11:43:22
【问题描述】:
下面是代码:
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect("1.1.1.1", username=username, password=password)
stdin, stdout, stderr = client.exec_command("set -units GB")
stdin, stdout, stderr = client.exec_command("vol show -vserver vs1 -volume test_volume -fields size")
return stdout.read()
从代码中获取的输出:
vserver volume size
------------------------ ------------------ ------
vs1 test_volume 1.07TB
设备输出:
test01::> set -units GB
test01::> vol show -vserver vs1 -volume test_volume -fields size
vserver volume size
------------------------ ------------------ ------
vs1 test_volume 1100GB
看起来 paramiko 没有在同一个频道中执行命令。我如何在 python 脚本中也获得值“1100GB”?
提示:两个命令都应该在同一个会话中执行,这样我就能得到设备中的预期输出
【问题讨论】:
标签: python python-2.7 python-2.x paramiko