I’m trying to call a Ruby script from a bash script, but no luck.
#!/bin/bash
ruby -v
works just fine, so I know that it’s not Ruby, but
#!/bin/bash
ruby bash_test.rb
does not. Here’s the fun part:
john@starfire:~/Desktop$ bash ubuntu_cmds.sh
(LoadError)h file or directory -- bash_test.rb
john@starfire:~/Desktop$ ls *.rb
bash_test.rb
Both files are sitting on my desktop.
ruby bash_test.rb
works just fine, too.
I’m new to bash scripting, so I’m pretty sure that I’m just making a stupid error.
I’m running Ubuntu 10.10 with Ruby 1.8.7. Thanks in advance for any help or advice.
EDIT: Deleted the .sh and the .rb and started over, and made sure to chmod +x the .sh, and it worked on the first try. I have no idea why. Thanks for the help, though.
Do you have a carriage return in the bash script after the file name ?
EDITED
Double check how the filename is being passed to ruby in the bash script.
Error output should be as below if the file wasn’t found
From what you are displaying as an error it appears that there is a carriage return that is being assumed by ruby as part of the filename so you are getting the following error output.