如何在python中传递exec_command中的变量值?
How to pass a variable value in exec_command in python?
我已将变量命令的值声明为
command =4
stdin, stdout, stderr = ssh.exec_command("pwd; ./test.sh command")
当我尝试 运行 上述命令时,它显示输出为
I am command
但它应该 return 为
I am 4
上述命令中是否缺少任何语法?
提前致谢
您将 "command" 作为字符串传递,但您需要将其值作为字符串传递:
ssh.exec_command("pwd; ./test.sh " + str(command))
我已将变量命令的值声明为
command =4
stdin, stdout, stderr = ssh.exec_command("pwd; ./test.sh command")
当我尝试 运行 上述命令时,它显示输出为
I am command
但它应该 return 为
I am 4
上述命令中是否缺少任何语法?
提前致谢
您将 "command" 作为字符串传递,但您需要将其值作为字符串传递:
ssh.exec_command("pwd; ./test.sh " + str(command))