【发布时间】:2014-04-14 05:06:13
【问题描述】:
我正在使用 ec2 实例,并试图在 ssh 到该实例之后在另一个实例上执行 ruby 脚本。
我有一个更新配置文件的 ruby 脚本,所以我需要以超级用户身份运行该脚本。当我在该实例上手动运行脚本时,sudo ruby recreate-532d01c.rb,出现的错误是
sudo: ruby: command not found
运行没有 root 权限的简单脚本可以工作,例如ruby file_1.rb。
使用 rvmsudo 代替 sudo 会执行带有警告的脚本,
ubuntu@ip-10-0-0-111:~$ rvmsudo ruby recreate-82bb000012.rb
Warning: can not check `/etc/sudoers` for `secure_path`, falling back to call via `/usr/bin/env`, this breaks rules from `/etc/sudoers`. Run:
export rvmsudo_secure_path=1
to avoid the warning, put it in shell initialization file to make it persistent.
In case there is no `secure_path` in `/etc/sudoers`. Run:
export rvmsudo_secure_path=0
to avoid the warning, put it in shell initialization file to make it persistent.
我尝试从要测试的实例之一的 rails 控制台执行以下命令,但它无法将 ruby 识别为命令
1.9.3-p545 :002 > system("ssh -i /home/ubuntu/.ssh/own_key.pem ubuntu@**.***.***.** ruby execute-52d.rb")
bash: ruby: command not found
我通过网络尝试了可能的解决方案,但无法解决问题。我为我的一个旧 aws 帐户运行了相同的配置,这是一个新创建的帐户。不确定这是否会以任何方式出现问题,因为当前 ec2 实例默认属于 vpc 并且在 2013 年 12 月之后有一些更改
【问题讨论】:
标签: ruby-on-rails ruby ssh amazon-ec2 ubuntu-12.04