Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On my Fedora 16 machine, I have an executable file named 'WarpImageMultiTransform', and I can run it when I cd into the folder that contains it:

[huangchao@localhost bin]$ ./WarpImageMultiTransform --help
Usage: 
./WarpImageMultiTransform ImageDimension moving_image output_image  -R reference_image --use-NN   SeriesOfTransformations--(See Below) 

But when I try to run it from other folder, it says the file doesn't exist:

[huangchao@localhost antsIntro]$  ls /home/huangchao/ANTs-1.9.x-Linux/bin/WarpImageMultiTransform
/home/huangchao/ANTs-1.9.x-Linux/bin/WarpImageMultiTransform
[huangchao@localhost antsIntro]$ ./home/huangchao/ANTs-1.9.x-Linux/bin/WarpImageMultiTransform --help
-bash: ./home/huangchao/ANTs-1.9.x-Linux/bin/WarpImageMultiTransform: No such file or directory

Does anyone know why?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

. at the beginning of a path means the path is relative to the current directory. / means it's an absolute path. This command:

ls /home/huangchao/ANTs-1.9.x-Linux/bin/WarpImageMultiTransform

lists absolute directory. But your second command:

./home/huangchao/ANTs-1.9.x-Linux/bin/WarpImageMultiTransform --help

Means: "execute /home/huangchao/ANTs-1.9.x-Linux/bin/WarpImageMultiTransform relatively to my current directory". This will work only if your current directory is /, as it will be equivalent to calling it without the period.

You need the period only to execute files from current directory, other dirs (relative or absolute) don't require a period.

share|improve this answer

I found the answer. Just using

[huangchao@localhost antsIntro]$ /home/huangchao/ANTs-1.9.x-Linux/bin/WarpImageMultiTransform --help

will work.

share|improve this answer

If you want to have easy access to an executable from any directory, you can add the location of the executable file to your $PATH. On *nix systems, if a word is typed into a terminal, the system will search through the directories in the user's path to find an executable with that name.

  • To see your current $PATH do

    echo $PATH
    
  • To add a directory called new_dir to your $PATH for the current session only do

    PATH=$PATH:/new_dir
    
  • To add a directory called new_dir to your $PATH for every session (assuming you are using bash), add this line to your $HOME/.bashrc file

    PATH=$PATH:/new_dir
    

So, in your case, you would add this line to .bashrc:

PATH=$PATH:/home/huangchao/ANTs-1.9.x-Linux/bin/

You will then be able to execute WarpImageMultiTransform simply by typing the command name wherever you are.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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