Previous Section  < Day Day Up >  Next Section

10.10. Storing Scripts

After creating successful scripts, it is customary to collect them in a common script directory and change your path so that the scripts can be executed from any location.

Example 10.50.

1   % mkdir ~/bin



2   % mv myscript ~/bin

3   % vi .login



   (In .login reset the path to add ~/bin.)

4       set path = ( /usr/ucb /usr /usr/etc ~/bin . )



5   (At command line)

    % source .login


EXPLANATION

  1. Make a directory under your home directory called bin, or any other name you choose.

  2. Move any error-free scripts into the bin directory. Putting buggy scripts here will just cause problems.

  3. Go into your .login file and reset the path.

  4. The new path contains the directory ~/bin, which is where the shell will look for executable programs. Because it is near the end of the path, a system program that may have the same name as one of your scripts will be executed first.

  5. By sourcing the .login, the path changes are affected; it is not necessary to log out and back in again.

    Previous Section  < Day Day Up >  Next Section