#!/bin/sh # # Infoschlep "schleps" the news article to the Info # area. To move the Info area, change the value of # Info_Home. # # Originally written by Steve Hanson # # Modified 6/97 by Chuck DeBaun to generate unique filenames. # Restructured and added commentary to # aid in maintenance. # Info_Home=/afs/fnal/products/Info /bin/cat >/tmp/infoin.$$ grep Subject /tmp/infoin.$$ | sed -e s/'Subject: '/""/ >/tmp/infosubject.$$ cp /tmp/infosubject.$$ /tmp/infoout.$$ grep Expires /tmp/infoin.$$ >>/tmp/infoout.$$ cat /tmp/infoin.$$ >>/tmp/infoout.$$ d=`date +%j` # # Initialize the file number field to the PID. # This will be unique on any given machine at # any specific time. # # Although the PID is not guaranteed to be # unique across machines, it is likely to be. # num=$$ # # Though unlikely, it is possible that the # intended filename is already in use. # # Increment the filenumber until the # conflict clears. # while [ -f $Info_Home/'n'${d}.$num ] do num=`/bin/expr $num + 1` done # # The resulting filename is "n""." # This isn't pretty or meaningful, but it is unique and # reasonably short. # f='n'${d}.$num cp /tmp/infoout.$$ $Info_Home/$f rm -f /tmp/infoin.$$ /tmp/infosubject.$$ /tmp/infoout.$$ # # With lock files and the above algorithm, it would be # possible to use simple sequential numbers for the # file number portion of the file name. Simply initialize # with # num=1 # when assured that it is safe to do so. # # This would further shorten the filename because there # will rarely be more than 99 articles added to Info # by this mechanism in a day. Normally there are no # more than five(5). #