Installing a Shell Script

A shell script is a file that contains commands written in a shell command language . You run (or "execute") a script as you would any other command. First, make sure that the script file is executable; if it isn't, you won't be able to execute it .

Generally, the administrator installs new shell scripts in the `/usr/local/bin' directory. If you are on a multi−user system and you are the only user liable to run a particular script, you can put it in a special directory in your home directory tree−−the `~/bin' directory is the standard recommendation here−−and then add that directory to your path Not all executable script files are shell scripts. The first line of a script contains the full path name of the shell or other program that is to interpret and execute the script; sometimes, the path may differ on your system.

from the one the script was written on, and so you may have to change this line.For example, a script may start with the following line:

#!/usr/local/bin/perl

This line means that the script is written in the perl language; the text after the `#!' is the full path name of the perl program, which in this case is `/usr/local/bin/perl'. If you try to execute this script and the system reports an error finding the file, you'll have to change that first line to correspond to the location of the perl binary on your system. The which tool will output this location. To find out where perl is installed on your system, type:\

$ which perl RET

If that command returns `/usr/bin/perl' or some path name other than /usr/local/bin/perl, you'll have to change the location in the first line of the script to the path name given:

#!/usr/bin/perl

NOTE: If the output of the which command returns nothing, that means that the perl program is not installed on your system at all; in that case, you should install the perl software.

Posted on: 17/12/2009








0 Comments
If you want to leave a comment please Login or Register