Problem when trying to run shell script : No such file or directory

you can run a bash script by using the following command

bash <location of the script file>

in your case

bash /home/abcdef/Desktop/jikesrvm/dist/production_x86_64-linux/rvm

it will work

what basically the . means is your current directory location.

if you are under your <user> folder then try doing this

./Desktop/jikesrvm/dist/production_x86_64-linux/rvm

it will work but first you should make the file executable using the following command

chmod +x ~/Desktop/jikesrvm/dist/production_x86_64-linux/rvm

While you are trying:

./home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm

shell will always treat . in front of a path as current directory and hence the path will always be a relative path. So, shell is trying to find an executable file in the location:

$PWD/home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm

which is wrong as you can see. You would run a executable script that is the current directory as ./script.sh.

You can actually simply run the executable by using the absolute path (given the script is executable):

/home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm

Or as ~ is expaneded by shell as $HOME:

~/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm

Or even just the name of the script if the directory containing the script is in the PATH environment variable.

Now if your script is Not executable, you can run it too without making it an executable by telling the shell which program will handle the script i.e. giving the script as an argument to bash (shell):

bash /home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm

Tags:

Bash

Scripts