繁体   English   中英

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

[英]Getting environment from .profile while executing a command through 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 . ./myscript.sh命令创建类似于新终端的内容。 我不要这种行为。 我想使用ssh命令来自动化构建过程,而无需手动关闭终端。 有没有办法做到这一点?

约翰,谢谢你的期待

. / source不会调用新的shell。 它在当前外壳程序的脚本中运行命令。 还有其他问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM