我正在尝试编写一个脚本,它将:
copy.sh
执行此任务的脚本)make
make
另一个位置复制到另一个位置。我的脚本如下所示:
#!/usr/bin/bash
BUILDSERV=me@server
BUILDDIR=/me/directory
#run my script that copies the files
./copy.sh
#TARGET is also a var in copy.sh so I make sure it's set properly here
TARGET=root@final_dest:/usr/bin/my_bin
ssh $BUILDSERV "cd $BUILDDIR && make && scp ./my_bin $TARGET"
Run Code Online (Sandbox Code Playgroud)
问题是我想作为其一部分运行的程序make
不在我的PATH
. 我.bash_profile
有一条export PATH=$PATH:/my/bin/
线,但是bash_profile
当我 ssh 进入时似乎没有被读取。
有没有办法更改我的 ssh 调用或脚本以使其读取我的 ssh 调用.bash_profile
?
以下应该工作:
ssh $BUILDSERV "source ~/.bash_profile && cd $BUILDDIR && make && scp ./my_bin $TARGET"
Run Code Online (Sandbox Code Playgroud)
所述source
外壳内置读取文件和执行相同的外壳中的命令(不同于简单地调用脚本,这将调用一个单独的壳)。
当作为登录shell调用bash
执行.bash_profile
,如果存在的话,以完全相同的方式source
做,所以效果是一样的。
归档时间: |
|
查看次数: |
3155 次 |
最近记录: |