#From: David Johnson <[email protected]>
#Subject: getit.shar
#To: [email protected]
#Date: Fri, 16 Jul 1993 04:01:52 -0700 (PDT)
#
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#       README
#       getit
#       getumich
#       prnumich
#       sample-input
# This archive created: Fri Jul 16 03:46:57 1993
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'README'
then
       echo shar: "will not over-write existing file 'README'"
else
cat << \SHAR_EOF > 'README'
Well don't get too excited, this is no big hack, and mostly made of stuff
I stole from here and there, basically the ftp script that is on sumex that
allows auto ftping and modified version of a  perl script written by
Jonathan Eunice ([email protected]) that beautifies (???) the mac
digests from umich.

Of course this isn't like skim.c that does almost everything for you
except get the files (if you like sumex :) but it is handier IMHO for
what is does do (and it doesn't involve compiling :)

What *does* it do you ask?  Well, this is the run down:

You run out and get a unix box :-)
Save a copy of the mac.archive.digest to a file.
Edit the file (with your favorite editor of course), deleting any of the
       programs you don't want (i.e. any line starting with a '/mac/...'
Save the file.
Type getit filename
Voila, all the files show up in a new directory.


How to set it up. (for the complete moron)

You sould have gotten the files:        README (well I sould say so :)
                                       getit*
                                       prnumich*
                                       getumich*
                                       sample-input

1) Make sure you have perl by typing 'perl -v'

2) Move the files 'getit','prnumich', and 'getumich' to your local bin directory
       If you don't have a local bin dir, edit the file '.cshrc' so that
       there is a line that says 'set lpath = ($HOME/bin)'
       Now find the line that starts with 'set path = (' and ad '$lpath '
       right after the '('
       It should now look like 'set path = ($lpath /blah/blah/blah/... .)'
       Type 'mkdir $HOME/bin'
       then type:      'mv getit $HOME/bin'
                       'mv getumich $HOME/bin'
                       'mv prnumich $HOME/bin'

3) Edit your .netrc file so that it includes this line:

machine mac.archive.umich.edu login anonymous password [email protected]

       Of course, substitiuting your email address for '[email protected]'
       If you don't have a .netrc file, just make one.
       Call it '$HOME/.netrc' and put it in your home directory.

5) Get a mac.archive.digest list.  Edit it so that all programs you don't
       want are deleted (that is all the lines that contain '/mac/...' ).
       Any line that starts with a / will be seen as a program to get.
       Save the file  (You can use the sample-input file to test getit)
       You might want to cut the mail headers out also (just in case :)

6) Type 'source $HOME/.cshrc' (or logout and log back in)

7) Type 'getit filename' (where filename is what you saved the edited digest as)

8) Wait

       You will eventually have the files in a new directory named
       'new-umich-files.month-hr:min:sec'


Enjoy!

--DAVE ([email protected])

ps- For those more in tune to the unix god, you can set getit to look in some
   other places for it's files, and there's a couple of other options avail.
   Look in the files getit and getumich.

pss- Let's be kind about when and how many files.  A nice thing for you to do
   would be to make a script file and use the 'at' command to get the files
   when the archive isn't so busy ( 'man at' for those interesed).
SHAR_EOF
fi
if test -f 'getit'
then
       echo shar: "will not over-write existing file 'getit'"
else
cat << \SHAR_EOF > 'getit'
#!/usr/bin/csh

if  $#argv == 0 then
echo " Usage: getit filename"
echo "         GetIt v1.0 David C. Johnson ([email protected])"
exit
else

set INPUT = $argv[1]
set SUPPORT_FILES_DIR = $HOME/bin
set NEW_DIR_NAME = "new-umich-files.`date +%h-%d-%T`"

mkdir $NEW_DIR_NAME
echo "/" | cat $INPUT - > $NEW_DIR_NAME/mac.temp.temp.temp # isn't that cute :-)
perl $SUPPORT_FILES_DIR/prnumich $NEW_DIR_NAME/mac.temp.temp.temp > $NEW_DIR_NAME/umich.files
cd $NEW_DIR_NAME
rm mac.temp.temp.temp
echo "bye" | cat umich.files - > mac.temp.temp.temp
rm umich.files
mv mac.temp.temp.temp umich.files
sh $SUPPORT_FILES_DIR/getumich

rm mac.archive.umich.edu.*      # comment out to save log transcript files
rm umich.files                  # comment out to save parsed ftp input file
#rm ../$INPUT                   # comment out to save original input file

exit
endif
exit
SHAR_EOF
chmod +x 'getit'
fi
if test -f 'getumich'
then
       echo shar: "will not over-write existing file 'getumich'"
else
cat << \SHAR_EOF > 'getumich'
#!/bin/sh
host=mac.archive.umich.edu
in=umich.files
out=$host.results
err=$host.errs
# How long to sleep between subsequent tries (in seconds):
#time=5         # Downright Nasty :-(
time=59         # One minute
#time=559       # Ten minutes
#time=3559      # An hour
#time=7159      # Two hours
echo "Starting to get files from $host." > $out
echo "Trying to reach $host at time:" >> $out
date +'%H:%M hrs; %d %h %y' >> $out
ftp $host < $in >> $out 2> $err
while test -s $err
do
 echo "Cannot connect now, will try again in $time seconds." >> $out
 sleep $time
 echo "Trying to reach $host at time:" >> $out
 date +'%H:%M hrs; %d %h %y' >> $out
 ftp $host < $in >> $out 2> $err
done
echo "File transfer successful!" >> $out
echo "File transfer completed at:" >> $out
date +'%H:%M hrs; %d %h %y' >> $out
SHAR_EOF
chmod +x 'getumich'
fi
if test -f 'prnumich'
then
       echo shar: "will not over-write existing file 'prnumich'"
else
cat << \SHAR_EOF > 'prnumich'
#!/usr/bin/perl
$= = 999999;
$first = 1;
while (<>) {
       chop;
       if (m=^/=) {            # pathname -- starts new entry
               if (!$first) {
                       $arr{$pathname} = $comment;
               }
               $pathname = $_;
               $first = 0;
               undef($comment);
       }
       elsif (/^\s*$/) {       # blank line
               next;           # skip it
       }
       elsif (/^\s*\d+\s+\d+\/\d+\/\d+\s+[\w\d]+/) {   # Infoline
               next;           # skip it
       }
       else {
               m/^\s*(\S.*)\s*$/;      # take only good stuff
               $comment = "$comment $1"; # append to comment
       }

}
@keys = keys(%arr);
@keys = sort(@keys);
foreach $key (@keys) {
       $key =~ m=^(/.+/)([\w\.]+)\s*$=;        # find line components
       $path = $1;
       $filename = $2;
       $comment = $arr{$key};
       $comment =~ s/^\s*//;
       write;                          # print line components
}
format STDOUT_TOP =
ascii