#! /bin/csh
ln 20-archive-requests requests-in-progress
if ($status) then
  if (! -e 20-archive-requests) then
    echo No archive requests to do
    exit(0)
  endif
  if (-e requests-in-progress) then
    echo Archiving already in progress: requests-in-progress exists
    exit(1)
  endif
  echo 
  echo Unexpected failure to ln 20-archive-requests requests-in-progress
  exit(1)
endif
rm 20-archive-requests
sort +4 -5 +5n -6 +6n -7 requests-in-progress -o sorted-temp
awk -f errors.awk sorted-temp
sort +7 -8 +8n -9 +9n -10 requests-in-progress -o sorted-temp
awk -f errors.awk sorted-temp
sort -u +4 -5 +5n -6 +6n -7 requests-in-progress -o atape-requests
sort -u +7 -8 +8n -9 +9n -10 requests-in-progress -o btape-requests
awk -f atapes.awk atape-requests >atapes
awk -f btapes.awk btape-requests >btapes
chmod +x atapes btapes
echo You can now do the retrieves by typing \"atapes\" or \"btapes\"
echo When you have finished, please send mail to the users involved
echo and then remove the file requests-in-progress
