|
Naming Conventions
Shell scripting The first line in any shell script should identify which shell interpreter to use. #!/bin/sh Bourne shell #!/bin/ksh Korn shell #!/bin/csh C shell The second line should be a blank comment. The next few lines should have the program name, programmer's name and any copyright information, and a brief description of what the program does. # my_prog.sh # David Johnson ©2000 under GNU copyleft license # # This script fixes every problem known to man, except the # one you have. It works best on Monday mornings while you # are sleeping. # (Here's a sample text block about the GNU license and disclaimer that you can cut-and-paste directly into your script file.) Here begins the body of the script. OS check In an effort to make scripts as generic as possible let's check to see if we are on NT or Solaris and take appropriate action.
Path names The standard distribution will normally go in the /opt/cassandra directory. In an effort to allow maximum flexibility with minimal headache we should check to see if the variable CASSANDRA_HOME exists. If not set CASSANDRA_HOME to be /opt/cassandra. Temporary files should go in $CASSANDRA_HOME/tmp. Unusual command problems under NT If the script uses a command that also exists in the windows path, i.e. sort, find, etc. then the script will need an explicit path to correctly execute if it can be run on both platforms. if [ $on_NT –eq "1" ] d:/nutc/mksnt/sort –u $file if [ $on_SOLARIS –eq "1"] sort –u $file That's all I have for now on shell scripts, but I am open to suggestions for more, better, or fewer standards. Other Scripts awk Scripting C programs C++ programs Perl Copyright ©2000-2004 The Cassandra Project. All rights reserved. web posted: 21 February 2000 last updated: 10 June 2004 Contact the webmaster for comments and/or questions. pages requested: |