我想在远程机器上执行一个shell脚本,我使用下面的命令实现了这个目标:
ssh user@remote_machine "bash -s" < /usr/test.sh
这个shell脚本在远程机器上成功执行了。现在我对脚本进行了一些修改,以从配置文件中获取一些值。脚本包含以下行:
#!bin/bash
source /usr/property.config
echo "testName"
property.config :
testName=xxx
testPwd=yyy
现在,如果我在远程机器上运行shell脚本,由于/usr/property.config在远程机器上不可用,因此我会收到“没有这样的文件”错误。
如何将配置文件与要在远程机器上执行的shell脚本一起传递?
scp
? - anishsanescp
? - sjsamstdin
发送它(ssh user@remote_host 'cat >/path/to/config.file; /remote/command' < /local/config.file
),但是scp是最可靠的方式。 - anishsane