There's difference between working directory and path; when you login to Linux, sh (or bash or whatever other default shell you have in /etc/passwd) is executed and your working directory is the user home directory you are using to login (you can get the working directory by running the command `pwd` after logging in) and not the path of your default shell! So, before running a script execute `pwd` to know what working directory will it have.
Anyway, when you run a shell script, a sub-shell is running to execute your script and not the same shell you are using to login.
Solve this issue by adding to the script the below line, this will change dynamically to the directory of your script wherever the script is located:
Code:
cd "$(dirname "$0")"