通过ssh执行命令时从.profile获取环境

时间:2010-03-31 06:15:39

标签: linux unix build ssh

我是linux / unix世界的新手。我想在远程机器上触发make。为此,我在远程机器上创建了一个小脚本,我想通过ssh执行。

脚本看起来像这样:

echo "loading .profile"
. ~/.profile
echo "profile loaded"
echo "starting gmake"
cd ~/helloWorld/
gmake all

我使用以下ssh命令调用脚本:

ssh user@remotehost "cd ~/helloWorld && ./myscript.sh"

当我执行此命令时,我的机器连接到远程机器。它告诉我配置文件已加载,然后我必须按[CTRL] + [D]继续脚本。所以似乎. ./myscript.sh命令创建了一个类似新终端的东西。我不想要这种行为。我想使用ssh命令自动化构建过程,而无需手动关闭终端。有没有办法做到这一点?

期待感谢你, 约翰

1 个答案:

答案 0 :(得分:1)

. / source不会调用新的shell。它在当前shell的脚本中运行命令。还有别的东西出了问题。

相关问题