I tried executing a script with this command:
./home/user/scripts/someScript
but it doesn't work:
No such file or directory
Any ideas?
I tried executing a script with this command:
./home/user/scripts/someScript
but it doesn't work:
No such file or directory
Any ideas?
The leading dot in your command means "relative to the current directory". Remove it and it'll refer to "the file
someScript
in the directory/home/user/scripts
:If you get "Permission denied", it's either because you do not have sufficient permissions to access the file in the directory of other users or because the file is not executable. To make it executable, run:
If your script needs to access resources in the same folder that it is being run from, and you have it specified as relative paths, then your script will break.
I always add a
cd $(dirname $0)
to the head of my script so the folder containing the script will be the root folder.Remove the
.
If you make the scrip executable with
chmod 755 <nameofscript>
to run it you only need to type the path to the script.When you see
./script
being used it telling the shell that the script is located on the same directory you are executing it. To use full path you typesh /home/user/scripts/someScript
.I tried many ways and that's working well with me:
I get some help from this answer.