1

我正在使用 Ruby MRI 1.8.7,并且我有一个连接到服务器并编辑 .bash_profile 文件的 Net-SSH 脚本。基本上添加了一些别名快捷方式。.bash_profile 内容示例:

alias test="echo 'test'"

现在,在通过源 .bash_profile 重新加载之前,我无法使用这些别名。问题是我似乎无法通过 Net-SSH 获取 .bash_profile。这是我迄今为止尝试过的:

ssh.exec!("source .bash_profile")
ssh.exec!("source /root/.bash_profile")
ssh.exec!("bash -c 'source ~/.bash_profile'")

现在,实际上我什至不需要 Net-SSH 中的别名,但我至少不想在服务器上手动获取 bash_profile。这里有什么问题,有什么解决方案吗?

4

2 回答 2

0

看跌期权

source $HOME/.bash_profile

在.bashrc的第一行

于 2014-02-18T21:16:30.050 回答
0

在 bash 中的双引号字符串中不能有 bang (!)。尝试这个: alias test='echo ''test!'''

于 2013-05-25T17:16:17.490 回答