【发布时间】:2014-02-19 05:16:30
【问题描述】:
我正在使用 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。 这是什么问题,有什么解决办法吗?
【问题讨论】:
-
您是否尝试执行与
source内联的命令以查看会发生什么? (例如source ~/.bash_profile && test) -
是的,它工作正常。您是否暗示 Ruby/SSH 会话不应该有任何不同?
-
我的意思是你尝试过通过 Ruby/SSH 执行该命令。也许采购不会在
ssh.exec!语句之间持续存在。 -
啊,我明白了。但它不起作用:“bash: test1: command not found\n”(来自 .bash_profile: alias test1="echo 'test'")
-
这个问题解决了吗?我有这个确切的问题。