prtcp

prtcp is a simple tool written to display the contents of "PATH-like" environmental variables in an informative manner. It was originally developed to display classpaths, hence the name PRinT ClassPath. But it is also helpful for displaying other PATH-like variables such as PATH and LD_LIBRARY_PATH.

As any Java programmer knows, all bets are off when the CLASSPATH is configured improperly. Sometimes this is difficult to detect when your CLASSPATH is full of junk and your only inspection mechanism is to print its contents with a mechanism like Unix's echo.

# echo $CLASSPATH /usr/local/lib:/usr/local/junit3.7/junit.jar:/usr/local/xerces/xerc
es.jar:/usr/local/xerxes.jar:/usr/local/xerces/xerces.jar:/usr/loca
l/log4j/log4j.jar
#
# prtcp
  1) d     /usr/local/lib
  2) f     /usr/local/junit3.7/junit.jar
  3) f     /usr/local/xerces/xerces.jar
  4) ne    /usr/local/xerxes.jar
  5) dup   /usr/local/xerces/xerces.jar
  6) f     /usr/local/log4j/log4j.jar

CLASSPATH character count: 151

#

Not only is the output from prtcp easier to read, the "entry indicators" give valuable status information about the entries. They have the following meaning.

d - directory entry
f - file entry
ne - non-existant
dup - duplicate entry

For environments where the length of the environment variable is a concern, the total length of its contents are displayed.

prtcp is written in C. Initially I tried to write it in Java. But I ran into the problem of changing the very environment I was trying to analyze. I wanted to look at the CLASSPATH, but to see it with a Java program, I had to change the CLASSPATH in order to include that Java program. C is much less invasive in this respect. Sure, you can argue that it requires that PATH be changed instead of CLASSPATH. But it's generally easier to toss the prtcp executable into some bin directory that is already in the PATH than to do the same thing for a Java class and the CLASSPATH.

You're invited to download the source and/or binary for your environment. prtcp is freeware. I don't have access to compilers for other Unix environments. But that's ok. You can write the same program with just a few lines in Awk or Perl.

prtcp.cThis is the Unix-ready source code. Compiling it on Windows requires two simple changes that are documented in the source code header. I changed the mime-type to .txt so that browsers wouldn't get confused.
prtcp.1A Unix man page for prtcp.
prtcp.exeWindows executable. I compiled this a while back with a VisualAge C++ compiler. I no longer have easy access to a Windows C/C++ compiler, so the version may be a little old.
prtcp-linux.gzAn executable for Linux compiled on a Redhat 7.1.
prtcp-aix.gzAn executable for AIX compiled on a version 4.3.3.