7

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?

  • You have two different paths so I am guessing a typo. – Panther Apr 20 '15 at 1:55
5

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
  • That worked!!!! I've been fighting this thing for hours. – devoured elysium Apr 20 '15 at 0:49
  • @devouredelysium To add, the . in front means it will look under /home/user. – TheWanderer Apr 20 '15 at 0:49
  • I thought the ./ signalized you wanted to run a script? – devoured elysium Apr 20 '15 at 0:50
  • @Zacharee1 The . actually means that it will look in the current directory and not necessarily the /home/user . if the curent directory is some other location it will not look in /home/user. ` ~` means that it will loo in the /home/user/ location. – Rumesh Apr 23 '15 at 6:30
3

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
1

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.

0

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.