0

I have a shell script

#!/bin/bash
echo "starting"
file="path_to_file/ruby_file.rb"
echo $file
ruby $file
echo "ended"

When I run it from the command line it works fine.

When I double click it on Finder it does not.

I have some puts on the ruby script that are being printed, but I'm making file operations (renaming) and they are not done. More than that, I get the following error:

(I have uncheck automatically close session when it ends)

-bash: shell_session_update: command not found

This is the result:

/path_to_shell_script/renamer.sh; exit;
starting
/path_to_ruby_script/renamer.rb
ruby is renaming
 ruby finished renaming
ended
logout
-bash: shell_session_update: command not found -> This doesn't happen when I run it from the command line.

1 Answer 1

1

When the shell script is run from the shell (that is, on the command line), it has the context of that shell, including the current directory setting and environment variable settings.

When it is run from the finder, it does not.

If you are using any relative filespecs, then, those files will probably not be found.

If your problem at runtime is only the current directory, then you could put a cd command in the script itself to switch to the correct directory.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. It works. :) I'm still getting "Sesison Ended (broken pipe). Restart it?" Any ideas?
Are you using iTerm? I googled "session ended broken pipe" and found this, indicating that an option has been added in a recent version to suppress this message: groups.google.com/forum/#!topic/iterm2-discuss/SeAdAifYVDo. You may need to update your iTerm software to have that option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.