#!/bin/csh ############################################################### # This script checks to see if this CD has already been linked # into the tree somewhere. The ID of the disc to check is # passed as the first command-line argument. # # It returns status 0 if there is one, 1 if there is not. It # returns 2 if there is a syntax error. It also prints the # path to the link if one exists. # # This script must be run in the "cds" directory, which has # the index directories under it. ############################################################## # Make sure we got a valid ID. set discid = $1 if (0 == `echo -n "$discid" | wc -c`) then echo "Usage: $0 id_to_check" exit 2 endif # Look in all of the subdirectories two levels down to see if # any of them are linked to a directory whose name includes # the ID passed in. set gotit = `ls -ld ?/?/* | grep "$discid" | wc -l` if ( 0 == $gotit ) then exit 1 endif set dirname = `ls -ld ?/?/* | grep "$discid" | awk '{print $9}'` echo "$dirname" exit 0