4 Replies Latest reply: Feb 4, 2011 4:17 PM by Linc Davis
Tehsimpl Level 1 Level 1 (0 points)
Hey, ive used to use Ubuntu and on Ubuntu you can just set the chosen file to be executable, but i cannot seen to find any way of doing that on OS 10.6. I just need a .sh file to run, thanks!

Macbook Pro 13", Mac OS X (10.6.6), 4GB Ram
  • leroydouglas Level 6 Level 6 (14,755 points)
    Important to cd to where the script is located, ex: cd Desktop

    you need to chmod to executable by:

    chmod +x foo.sh
  • beenlab Level 1 Level 1 (0 points)
    navigate to the directory of the file.

    run "chmod +x filename.sh" to make the script executable.

    then run "./filename.sh" to activate the script.
  • BobHarris Level 6 Level 6 (14,625 points)
    Since Mac OS X at the shell prompt behaves the same as most other Unix implementation with respect to running a script (including Ubuntu), I'm not sure I understand why you thing they are different.

    others have pointed out that the script must be executable, and if you are not in the same directory as the script, you either need to 'cd' to that directory, or use a /full/path/to/the/script.sh

    You can also add the script's directory to your PATH environment variable via .bash_profile, or put the script in one of the directories already covered by your PATH environment variable.

    Or are you talking about starting the script from the Ubuntu desktop by double-clicking on it? If that is the case, then double-clicking on a shell script from the Mac OS X Finder needs the shell script to both be executable, and have a suffix of .command

    If any of the replies so far have not answered your question, please feel free to provide additional information.
  • Linc Davis Level 10 Level 10 (146,020 points)
    +... double-clicking on a shell script from the Mac OS X Finder needs the shell script to both be executable, and have a suffix of .command+

    The suffix is not necessary:
    cat > test << EOF
    #! /bin/sh
    echo "Hello world!"
    EOF
    chmod +x test
    open !$