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.

I have a file named scanner:

#!/bin/sh
python lexAnalyser.py $*

I want it to run as $ scanner test.txt instead of $ ./scanner test.txt.

Thanks for any help you can give. I am just starting to use Linux and am trying to get my boots on.

share|improve this question

migrated from stackoverflow.com Oct 17 '12 at 8:22

This question came from our site for professional and enthusiast programmers.

    
Why would you want to do that? ./ tells shell that the preceeding file is an executable script –  Arpit Oct 16 '12 at 5:44
    
set PATH= .:$PATH (maybe to much csh?) –  Joseph Quinsey Oct 16 '12 at 5:45
1  
@Arpit Well it just tells the shell to execute that program in the current directory. –  squiguy Oct 16 '12 at 5:47
    
Slight correction: in your .bashrc, put export PATH=$PATH:. –  Joseph Quinsey Oct 16 '12 at 5:53
1  
@Arpit: No, the ./ tells the shell that it's in the current directory. –  Keith Thompson Oct 16 '12 at 6:25

3 Answers 3

up vote 2 down vote accepted

You can do:

$ ./scanner test.txt
$ PATH=$PATH:$PWD
$ scanner test.txt

but it's preferable to have $HOME/bin in your path and your scripts there.

share|improve this answer
    
+1 for both giving an actual answer, as well as mentioning $HOME/bin. (And if you don't want to move the script to there, you can always symlink it. I don't know why you'd want that, but it's an option.) –  Michael Kjörling Oct 17 '12 at 8:41

You can put the file in one of the paths specified by $PATH, for example, you can copy it to /usr/bin and then the shell will automatically recognize it by name without typing its full path.

share|improve this answer
  1. Add the directory that scanner is in to your path
  2. Move the file scanner to a directory that's already in your path.
  3. Alias scanner to the full path of where the file is.
share|improve this answer

Your Answer

 
discard

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