Command not found for shell script

bashcommand lineterminal

I created the following bash script in OS X 10.7.5:

$ cd ~/Documents/github/scripts
$ vim hello_world.sh


#!/bin/bash

clear

echo "The script starts now."

echo "Hi, $USER!"

echo "I will now fetch you a list of connected users:"
echo
w
echo

echo "I'm setting two variables now."
COLOUR="black"
VALUE="9"
echo "This is a string: $COLOUR"
echo "AND this is a number: $VALUE"
echo

echo "I'm giving you back your prompt now."
echo

Then I make sure it is executable:

$ chmod ugo+rwx hello_world.sh
$ ls -l
-rwxrwxrwx  1 GuardDog_02  staff  325 Mar 13 18:51 hello_world.sh

Then I add the directory to the contents of the PATH variable:

$ vim ~/.profile
export PATH=/Users/GuardDog_02/QtSDK/Desktop/Qt/474/gcc/bin/:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/X11/bin:/usr/local/mysql/bin
PATH=$PATH:/Users/GuardDog_02/Documents/github/scripts
export PATH

I then run the following to have the effect applied:

$ . ~/.profile

Then I open a new controlling terminal window, and I run hello_world.sh, but get command not found:

$ hello_world.sh
-bash: hello_world.sh: command not found

Why isn't the shell script recognized from the interactive bash shell in the controlling terminal? I tried the same thing in Ubuntu and it worked just fine.

Best Answer

Do you have a ~/.bash_profile? If so, then that will be preferred over the ~/.profile startup script. Next, verify the setting of your path (echo $PATH). Also (and this may be a dumb question) are you actually logged in as GuardDog_02? In other words, is ~ identical to /Users/GuardDog_02?