CS 207 Programming Examples, Fall 2002

  1. An example PAL program: add.pal.

  2. You might find the shell script pdp handy. To use it, make a subdirectory called "bin" in your home directory, and put pdp in that directory. Next, change the protections on pdp to make it executable (the command "chmod 755 ~/bin/pdp" will do the job). Then, edit the .cshrc file (or .cshrc.linux, if you have one of those) that can be found in your home directory. You should have a line in that file that looks something like this:

    set path=(. /usr/bin /usr/local/bin /bin /usr/local/kde/bin)

    It's probably longer than this, but I've shortened my "set path" line for simplicity in this example. Change this line to include "~/bin":

    set path=(. /usr/bin /usr/local/bin /bin /usr/local/kde/bin ~/bin)

    What you've done here is to tell the command shell (the program that prompts you and executes your commands) where you want it to look for commands, and in what order. So, for example, when I type a command, the shell looks in "." (the current directory) first, then in /usr/bin, then in /usr/local/bin, etc. Note that some people have the "." at the end, which is why many 117 students get confused when they name their programs "sort" or "test", which are also UNIX commands.

    The last thing you need to do is type "source .cshrc" while you're in your home directory to activate the new path. After that, pdp will be a command you can use.





Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057
(507) 646-4364, jondich@carleton.edu