I'm working with ec2 instances and was trying to execute a ruby script on another instance after ssh to that instance.
I have a ruby script which updates configuration files, so i need to run that script as super user. when i run the script manually on that instance,
sudo ruby recreate-532d01c.rb, the error that comes is
sudo: ruby: command not found
Running simple scripts with no root permissions works, eg.
Using rvmsudo in place of sudo executes the script with warning,
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.
I tried to execute the below command from rails console of one of the instance to test and it fails to recognize ruby as command
1.9.3-p545 :002 > system("ssh -i /home/ubuntu/.ssh/own_key.pem ubuntu@**.***.***.** ruby execute-52d.rb") bash: ruby: command not found
I tried with possible solutions over web, but could not resolve the issue. I have the same configuration running for one of my old aws acount, this is a newly created account. Not sure if this could be issue in any way as currently ec2 instances fall under vpc by default and have some changes after dec 2013