我想在命令send中使用变量发送到shell
以下是代码片段
vlans= ["2150"]
def fn():
client1=paramiko.SSHClient()
#add missing client key
client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())
#connect to switch
client1.connect(HOST,username=USER,password=PASS,port=PORT)
print "SSH connection to %s established" %HOST
remote_conn = client1.invoke_shell()
for i in vlans:
remote_conn.send("\n")
remote_conn.send("configure \n")
remote_conn.send("no ManagedElement=1,Transport=1,Bridge=0-26,Vlan=$vlans\n")
time.sleep(1)
output = remote_conn.recv(10000)
print output
client1.close()
fn()
如何在下面的行中使用变量 vlans :
remote_conn.send("没有ManagedElement = 1,Transport = 1,Bridge = 0-26,Vlan = $ vlans \ n")
答案 0 :(得分:0)
您可以使用VarRange = Cells(1, 3).Column
MsgBox Range(Cells(1, VarRange), Cells(20, VarRange)).Address
str.format()
答案 1 :(得分:0)
正确的格式应如下所示:
<img src="./image.jpg">
现在工作正常。
感谢@Ahsanul Haque提示:)