Listing 1: RPTRTR
#!/bin/ksh
#
# RPTRTR report router. Note how this script is in a .bin dir.
# This is to keep the path to report files short while protecting
# this executable. Use cc2dist, mkdistdir, mkdist, mkchmod and
# chmodirs to create cc:Mail dirs and set the correct permissions.
# This program must be run as cronned by psoft and other UNIX uids.
#
# By R. Holoch 2/6/96
# Updated 7/9/96 - include multi file email
#
#
# Global vars
#
DISTLIST=/home/reports/.bin/distlist
RPTDIR=/home/reports
RPTFILES=`ls $RPTDIR'`
#
# Send files to regional file servers via PC ftp server and cleanup
#
goftp()
{
cd $RPTDIR/$loc
ftp -i << eofftp
open pswin
anon
cd p:
cd ps
cd reports
cd $loc
mput *
dir
eofftp
if [ -f $RPTDIR/$loc/* ]
then
rm -f $RPTDIR/$loc/*
fi
}
#
# Send files via smtp gateway and cleanup after the send
#
gomail()
{
MAILFILES=`ls $RPTDIR/$loc`
u=0
for mfile in $MAILFILES
do
u=`expr $u + 1`
eval part$u="$mfile"
cat $RPTDIR/$loc/$mfile | mail $loc"@iplink"
rm -f $RPTDIR/$loc/$mfile
done
}
#
# Move accidents out of reports home to a "collector bucket"
#
if [ -f $RPTDIR/*.lis ]
then
mv $RPTDIR/*.lis $RPTDIR/lafao
fi
#
# Loop through all directories looking for files to send.
# Everything gets mailed except regional server named
# directory contents. Ignore parent dirs.
#
l=0
for loc in $RPTFILES
do
l=`expr $l + 1`
eval part$l="$loc"
case $loc in
lafao)
cd $RPTDIR/$loc
goftp
;;
london)
cd $RPTDIR/$loc
goftp
;;
.)
;;
..)
;;
*)
gomail
;;
esac
done
# End of File
|