Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

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

Writer Sebastian Wright

I'm trying to run the following command on bash:

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

which is giving me a

bash: ./home/abcdef/Desktop/jikesrvm/dist/production_x86_64-linux/rvm: No such file or directory

rvm is a bash file, and it does run ok when I attempt to run it from its own folder (production_x86_64-linux). It works also fine if I attempt to run it when opening the terminal in its parent folder, for instance, or even its parent-parent folder.

I've run it over with dos2unix just in case and I've also checked its executing permissions, which seem to be fine.

What am I missing here?

1

4 Answers

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
4

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

When you use ./ to execute a file, it will look in the current folder (.) for a folder named home instead of starting from the root (/) directory.

Using the bash command explicitly like in bolzano's answer starts from the root directory instead of the one you're in.

To use the command without bash you could enter

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

or

Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm

from your home directory assuming it is marked executable.

In addition to the other answers
What you tried was almost fine... But you forgot the extension .sh
- In your case
./home/abcdef/Desktop/jikesrvm/dist/production_x86_64-linux/rvm.sh
- or
cd /home/abcdef/Desktop/jikesrvm/dist/production_x86_64-linux
./rvm.sh

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy