Shell script won’t run ruby script file

shell

My shell script (my_shell.sh) won't run the ruby script (ruby_script_1.rb) in it.

my_shell.sh:

#!/bin/sh
# Invoke the ruby script here

./ruby_script_1.rb

It could not find where the ./ruby_script_1.rb is, thus errors:

# sudo my_shell.sh

: No such file or directory.

My ruby script is permission of 777. Any help is appreciated.

Best Answer

I'm using Fedora 19, i did little test, sudo uses

 Defaults    env_reset 

and

 Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin

in few worods, with this two directive, sudo uses his own env variables

commenting this two options in /etc/sudoers and adding my current working directory to my PATH it's work

 sudo sudotest.sh 
 + ./ruby.rb
 hello world

your directory scripts isn't in the root secure_path

Related Topic