本文介绍了在远程SSH命令传递变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够用ssh从我的计算机上运行一个命令,并通过环境变量$ BUILD_NUMBER
I want to be able to run a command from my machine using ssh and pass through the environment variable $BUILD_NUMBER
下面就是我想:
ssh pvt@192.168.1.133 '~/tools/myScript.pl $BUILD_NUMBER'
$ BUILD_NUMBER设置使得SSH调用的机器上,自变量不远程主机上存在,它不会回升。
$BUILD_NUMBER is set on the machine making the ssh call and since the variable doesn't exist on the remote host, it doesn't get picked up.
我如何通过$ BUILD_NUMBER的价值?
How do I pass the value of $BUILD_NUMBER ?
推荐答案
如果您使用
ssh pvt@192.168.1.133 "~/tools/run_pvt.pl $BUILD_NUMBER"
而不是
ssh pvt@192.168.1.133 '~/tools/run_pvt.pl $BUILD_NUMBER'
你的shell将插值 $ BUILD_NUMBER
之前发送命令字符串到远程主机。
your shell will interpolate the $BUILD_NUMBER
before sending the command string to the remote host.
这篇关于在远程SSH命令传递变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!