I know there is a script available on the site, but what the heck...this is
what I use.
I started writing provisions for venix but never finished. We don't have any
NT stations, so it was not consider when I wrote this.
It's been running from cron. Somedays just a checkpoint, others, a complete
saveall and remote copy to our development system.

#!/bin/sh
#####################################################################
#    Script:   cputil.sh                                            #
#    Author:   jdykes                                               #
#      Date:   4/11/2000                                            #
#  Function:   This script can perform upload, shrink, checkpoint,  #
#              and saveall of all of the CP/GW hosted by the AP/AW  #
#              that executes this script.                           #
#                                                                   #
#  Arguments:  -ck #   Performs a Checkpoint only.                  #
#              -rc     Performs a Remote copy only.                 #
#              -sv #   Performs a Saveall only.                     #
#              -us #   Performs an Upload and Shrink.               #
#              -alc #  Performs an Upload, Shrink, and local        #
#                      Saveall.                                     #
#              -alr #  Performs an Upload, Shrink, and both a local #
#                      and remote copy saveall.                     #
#              -usc #  Performs an Upload, Shrink, and Checkpoint.  #
#               # is used if a list of defined list of CP/GW's is   #
#                 to used. The reasoning for this is to break up    #
#                 the task on large system across different times   #
#                 or days. The # will be a number corresponding to  #
#                 the list name. Example: 1 = CPGW1.lst. If no      #
#                 number is given, then all of the configured       #
#                 CP/GW's will be used.                             # 
#                                                                   #
#       Files: cputil.sh     This script                            #
#              sfiles        A directory containing various         #
#                            scratch files.                         #
#              CPutil.rpt    A report documenting the script's      #
#                            actions.                               #
#                mail.log    A log of the e-mail service messages.  #
#               CPGW#.lst    May or may not be present. Used if     #
#                            script is only to be used against      #
#                            a defined list of CP/GW's.             #
#                                                                   #
#       Notes: Use Only Upload, Shrink, or CheckPoint on a Venix    #
#              based system. There are no provisions in this script #
#              to check disk space in Venix.                        #
#              Scripts assumes remote host is available.            #
#     Updates:                                                      #
#              04/27/00  Now reads CP/GW list from /etc/cplns       #
#                        instead of /usr/fox/sp/files/ciofiles.     #
#                        The latter also contains Foxboro           #
#                        "intelligent" devices.                     #
#                                                                   #
#              07/19/00  Modified remote copy to include a bkup     #
#                        copy on the remote host. Added the feature #
#                        of being able to provide a defined list of #
#                        CP/GW's rather then all in the system.     #
#                                                                   #
#              07/31/00  Added pinging remote host to insure it is  #
#                        online.                                    #
#####################################################################
# Definitions
Arg=$1                              # Argument supplied from the 
                                    # command line.
Bounce=no                           # Used to when host is NOT     
                                    # connected to the LAN and
                                    # we are using another machine
                                    # to copy the files to archive.
                                    # This copy of this script must 
                                    # be on the other machine.
CPln=/etc/cplns                     # CP/GW list.
CPtime=480                          # Checkpoint timeout setting.
                                    # Fox Doc recommends at least
                                    # 300 seconds before timeout.
Dir=/usr/prog/bbu_dcs/util/saveall  # Working directory.
Host=`uname -n`                     # Local station name.
List=$2                             # A list of CP/GW to perform
                                    # a task on.
Log=$Dir/cputil.rpt                 # Log file.
OP=`uname -s`                       # OS type SunOs or Venix.
Rhost=REMOTE_SYSTEM_NAME            # Remote station name.
Sdir=$Dir/sfiles                    # Scratch file directory.
SPdir=/usr/fox/sp                   # Foxboro misc. parmeters 
                                    # directory.
SSp=2800                            # Space required per CP/GW in KB.
                                    # Currently 2.8M or 2800K.
SysPrt=/dev/LP13                    # System Printer to receive
                                    # report. This will be LogMate.
#####################################################################
# Dependent Definitions 
if [ $OP = "VENIX" ]
   then Api=/usr/fox/ciocfg/api     # Foxboro ICC API VENIX path.
        Tools=/usr/fox/bin/tools    # Foxboro tool VENIX path.
        Savehm=/usr                 # Saveall home VENIX.
        Savenm=Savealls             # Saveall directory name VENIX.
        Savedir=$Savehm/$Savenm     # Saveall directory VENIX.
   else Api=/opt/fox/ciocfg/api     # Foxboro ICC API SunOs path.
        Tools=/opt/fox/bin/tools    # Foxboro tool SunOs path.
        Savehm=/opt                 # Saveall home SunOs.
        Savenm=Savealls             # Saveall directory Name SunOs.
        Savedir=$Savehm/$Savenm     # Saveall directory SunOs.
fi
#####################################################################
# Remove previous scratch files and directory if they exist.
if [ -d $Dir/sfiles ]
    then rm -r $Dir/sfiles
         mkdir $Dir/sfiles
    else mkdir $Dir/sfiles
fi
#####################################################################
# Start of Subroutines  Note:Subs must be read before being called. #
#####################################################################
# Obtain the configured cp/gw on the system subroutine.
Get_cpgw()
{
if [ $List  ]
   then echo "Task: Use CP/GW's as defined in CPGW"$List".lst." >> $Log
        cat CPGW$List.lst > $Sdir/cpgw.lst 
   else echo "Task: Obtain Configured CP/GW's Names." >> $Log
        echo "Reading configured CP/GW as listed in "$CPln"." >> $Log
        cat $CPln > $Sdir/cpgw.lst
        if [ -s $Sdir/cpgw.lst ]
           then echo "Configured CP/GW list has been created." >> $Log
           else echo "CP/GW list has failed." >> $Log
           echo "This script needs run on the hosting AP/AW station." >>
$Log
           echo "End of report." >> $Log
           exit 1
        fi
fi
}
#####################################################################
# Check if the CP/GW is online and/or locked subroutine.
Chk_stat()
{
 echo "Task: Check Processor status for "$CP"." >> $Log
 if [ `$Tools/fist $CP | grep $CP |awk '{print $2}'` != "Not" ]
     then
        stat=online
     else
        stat=offline
 fi
 if [ -f $SPdir/locks/f$CP+ ]
     then
        lock=locked
     else
        lock=unlocked
 fi
}
#####################################################################
# Check Local Disk Space subroutine.
Chk_Dsk()
{
 echo "Task: Check Disk space." >> $Log
 if [ $OP != "VENIX" ]
    then
        CPt=`wc -l < $Sdir/cpgw.lst|awk '{print $1}'`     
        echo "Total number of CP&GW's is "$CPt"." >> $Log
        NSp=`expr $CPt '*' $SSp + 100000` #2 * 1.4 Diskette + 100MB Reserve.
        ASp=`df -k|grep dsk|grep opt| awk '{print $3}'` #Space Avail In opt.
        echo "Needed disk space is "$NSp" KB." >> $Log
        echo "Available disk space is "$ASp" KB." >> $Log
        if [ $NSp -ge $ASp ]
           then
               echo "Not enough disk space available." >> $Log
               echo "End of report." >> $Log
               exit 1
        fi
    else
        echo "Disk spaced not checked on a Venix system." >> $Log
 fi
}
#####################################################################
# Remote copy of saveall data subroutine.
Rem_sav()
{
  echo "****** REMOTE COPY SAVEALL TO "$Rhost" ******" >> $Log
  echo "Task: Determine if remote host is online." >> $Log
  if [ `ping $Rhost|awk '{print $3}'` = "alive" ]
     then 
          echo $Rhost" is online." >> $Log
          echo "Task: Determine disk space needs." >> $Log
          blk=`du -s $Savedir/Current|awk '{print $1}'`
          Byte=`expr $blk '*' 512` # Convert blocks to bytes.
          Ksz=`expr $Byte / 1000 + 100000` # KB needed times 2 + 100MB
Reserve.
          RKsz=`rsh $Rhost df -k|grep dsk|grep opt|awk '{print $3}'`
          echo $Ksz" KB needed." >> $Log
          echo $RKsz" KB available at "$Rhost"." >> $Log
          if [ $Ksz -lt $RKsz ] 
             then 
                 echo "Remote copy started for "$Host" on "`date` >> $Log
                 if [ $Bounce = "yes" ]
                    then
                        echo "Task:Copy Saveall data for Bounce." >> $Log
                        rcp -rp /opt/Savealls $Rhost:/opt
                    else
                        Rls=`rsh $Rhost ls -1 $Savehm|grep $Savenm`"Not"
                        if [ $Rls = "Not" ]
                           then
                               echo "Making "$Savedir" on "$Rhost"." >> $Log
                               rsh $Rhost mkdir $Savedir
                               rsh $Rhost mkdir $Savedir/bkup
                        fi
                        sleep 1
                        Rls=`rsh $Rhost ls -1 $Savedir|grep $Host`"Not"
                        if [ $Rls = "Not" ]
                           then
                               echo "Making "$Savedir"/"$Host" on "$Rhost"."
>> $Log
                               rsh $Rhost mkdir $Savedir/$Host
                           else
                                echo "Copying previous archive to bkup
directory." >> $Log
                                rsh $Rhost cp -rp $Savedir/$Host
$Savedir/bkup
                        fi
                        sleep 5
                        echo "Copying saveall data to "$Rhost"." >> $Log
                        rcp -rp $Savedir/Current/* $Rhost:$Savedir/$Host 
                        echo "Remote copy finished for "$Host" on "`date` >>
$Log
                 fi
            else echo $Rhost" doesn't have enought disk space." >> $Log
          fi
      else
          echo $Rhost" is either Not online or Not available." >> $Log
  fi
  if [ $Bounce = "yes" ]
     then
         sleep 15
         echo "Task: Bounce saveall data to archive." >> $Log
         rsh $Rhost $Dir/cputil.sh -rc
         sleep 160
         echo "Task: Removing archive from "$Rhost >> $Log
         rsh $Rhost /bin/rm -r $Savedir
  fi
}
#####################################################################
# Upload and Shrink the CP or GW subroutine.
Up_shk()
{
 echo "****** UPLOAD/SHRINK ******" >> $Log
 exec < $Sdir/cpgw.lst
  while read CP
 do
  Chk_stat    
  if [ $stat = "online" ] && [ $lock = "unlocked" ]
  then   
    echo "Task: Upload and Shrink." >> $Log
    echo "Building ICC task for "$CP >> $Log
    echo "OPEN "$CP" MODIFY AUTOSAVE" > $Sdir/$CP.tsk
    echo "UPLOAD" >> $Sdir/$CP.tsk
    echo "SHRINK" >> $Sdir/$CP.tsk
    echo "CLOSE" >> $Sdir/$CP.tsk
    echo "EXIT" >> $Sdir/$CP.tsk
    echo "Upload & Shrink started for "$CP" on "`date` >> $Log
    $Api/iccdrvr.tsk -i $Sdir/$CP.tsk -o $Sdir/icc.log -n echo
    cat $Sdir/icc.log >> $Log
    echo "Upload & Shrink finished for "$CP" on "`date` >> $Log
    sleep 1
  else
    echo "$CP is "$stat" and "$lock"." >> $Log
  fi 
 done
}
#####################################################################
# Checkpoint the CP or GW subroutine.
Chk_Pnt()
{
 echo "****** CHECKPOINT ******" >> $Log
 exec < $Sdir/cpgw.lst
  while read CP
 do
  Chk_stat
  if [ $stat = "online" ] && [ $lock = "unlocked" ]
  then
    echo "Task: Checkpoint." >> $Log
    echo "Building ICC task for "$CP >> $Log
    echo OPEN $CP MODIFY AUTOSAVE  > $Sdir/$CP.tsk
    echo CHECKPOINT $CPtime >> $Sdir/$CP.tsk
    echo CLOSE   >> $Sdir/$CP.tsk
    echo EXIT    >> $Sdir/$CP.tsk
    echo "Checkpoint started for "$CP" on "`date` >> $Log
    $Api/iccdrvr.tsk -i $Sdir/$CP.tsk -o $Sdir/icc.log -n echo
    cat $Sdir/icc.log >> $Log
    echo "Checkpoint finished for "$CP" on "`date` >> $Log
    sleep 1
  else
    echo "$CP is "$stat" and "$lock"." >> $Log
  fi
done
}
#####################################################################
# Upload, Shrink, and Checkpoint the CP or GW subroutine.

Us_ChkPnt()
{
 echo "****** UPLOAD/SHRINK AND CHECKPOINT ******" >> $Log
 exec < $Sdir/cpgw.lst
  while read CP
 do
  Chk_stat
  if [ $stat = "online" ] && [ $lock = "unlocked" ]
  then
    echo "Task: Upload, Shrink, and Checkpoint." >> $Log
    echo "Building ICC task for "$CP >> $Log
    echo OPEN $CP MODIFY AUTOSAVE  > $Sdir/$CP.tsk
    echo UPLOAD  >> $Sdir/$CP.tsk
    echo SHRINK  >> $Sdir/$CP.tsk
    echo CHECKPOINT $CPtime >> $Sdir/$CP.tsk
    echo CLOSE   >> $Sdir/$CP.tsk
    echo EXIT    >> $Sdir/$CP.tsk
    echo "Upload,Shrink, and Checkpoint started for "$CP" on "`date` >> $Log
    $Api/iccdrvr.tsk -i $Sdir/$CP.tsk -o $Sdir/icc.log -n echo
    cat $Sdir/icc.log >> $Log
    echo "Upload,Shrink, and Checkpoint finished for "$CP" on "`date` >>
$Log
    sleep 1
  else
    echo "$CP is "$stat" and "$lock"." >> $Log
  fi
done
}
#####################################################################
# SaveAll to the CP/GW subroutine.
Saveall()
{
Chk_Dsk       # Run the check local disk space subroutine.
  echo "****** SAVEALL ******" >> $Log
        if [ ! -d $Savedir ]
           then echo "Making Saveall directory at "$Savedir >> $Log
                mkdir $Savedir
                sleep 1
                mkdir $Savedir/Current
                mkdir $Savedir/Bkup
        fi
        exec < $Sdir/cpgw.lst
        while read CP
        do
        Chk_stat
        if [ $stat = "online" ] && [ $lock = "unlocked" ]
           then echo "Task: Saveall." >> $Log
                echo "Saveall started for "$CP" on "`date` >> $Log
                if [ ! -d $Savedir/Current/$CP ]
                   then echo "Make directory for "$CP"." >> $Log
                        mkdir $Savedir/Current/$CP
                        sleep 1
                   else echo "Directory for "$CP" exists." >> $Log
                        echo "Copying previous SaveAll for "$CP" to
"$Savedir"/Bkup." >> $Log
                        cp -pr $Savedir/Current/$CP $Savedir/Bkup
                        sleep 1
                        rm -r $Savedir/Current/$CP > /dev/null
                        sleep 1
                        mkdir $Savedir/Current/$CP
                        sleep 1
                fi
                sleep 5
                echo "Saveall for "$CP" made in "$Savedir"/Current/"$CP >>
$Log
                cd $Api # Errors received from save_all.awk if this isn't
done.
                $Api/save_all $CP $Savedir/Current/$CP >> $Log
                echo "Saveall finished for "$CP" on "`date` >> $Log
           else echo "$CP is "$stat" and "$lock"." >> $Log
        fi 
done
}
############################################################################
###
# Main Body of Script.
# Start Log.
echo "Start Of Report." > $Log
date >> $Log
# Execute subroutines based on the arguement provided.
case $Arg in
        -ck) echo "CHECKPOINT ONLY SELECTED." >> $Log
             Get_cpgw
             Chk_Pnt;;
        -rc) echo "REMOTE COPY OF SAVEALL DATA SELECTED." >> $Log
             Rem_sav;;
        -sv) echo "SAVEALL ONLY SELECTED." >> $Log
             Get_cpgw
             Saveall;;
        -us) echo "UPLOAD AND SHRINK ONLY SELECTED." >> $Log
             Get_cpgw
             Up_shk;;
       -alc) echo "UPLOAD, SHRINK, CHECKPOINT, AND LOCAL SAVEALL SELECTED."
>> $Log
             Get_cpgw
             Us_ChkPnt
             Saveall;;
       -alr) echo "UPLOAD, SHRINK, CHECKPOINT, AND LOCAL/REMOTE SAVEALL
SELECTED." >> $Log
             Get_cpgw
             Us_ChkPnt
             Saveall
             Rem_sav;;
       -usc) echo "Upload, Shrink, and CheckPoint Only Selected." >> $Log
             Get_cpgw
             Us_ChkPnt;;
          *) echo "Improper arguement supplied." >> $Log;;
esac
date >> $Log
echo "End Of Report." >> $Log
# Send report via e-mail and send it to the system printer(LogMate)
if [ $Bounce = "yes" ]
   then
      rcp -pr $Log $Rhost:$Dir
      sleep 5
      rsh $Rhost /usr/lib/sendmail -v [EMAIL PROTECTED] < $Log >
$Dir/mail.log
   else /usr/lib/sendmail -v [EMAIL PROTECTED] < $Log > $Dir/mail.log
fi
cat $Log > $SysPrt



> -----Original Message-----
> From: Chris A Levingston [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, August 25, 2000 1:41 PM
> To:   [EMAIL PROTECTED]
> Subject:      Automating Saveall's
> 
> 
> 
> Has anyone seen a procedure to automate Saveall's.  we have alot of
> compounds
> that will not save to disk because they are bigger than 1.44 meg.
> 
> Sincerely,
> Chris Levingston
> ExxonMobil Chemical Company
> Process Control, Beaumont Area Engineering Organization
> 409 839-1548 Telephone
> 409 839-1751 Facsimile
> 
> 
> 
> -----------------------------------------------------------------------
> This list is neither sponsored nor endorsed by the Foxboro Company. All 
> postings from this list are the work of list subscribers and no warranty 
> is made or implied as to the accuracy of any information disseminated 
> through this medium. By subscribing to this list you agree to hold the 
> list sponsor(s) blameless for any and all mishaps which might occur due to
> 
> your application of information received from this mailing list.
> 
> To be removed from this list, send mail to 
> [EMAIL PROTECTED] 
> with "unsubscribe foxboro" in the Subject. Or, send any mail to
> [EMAIL PROTECTED]

-----------------------------------------------------------------------
This list is neither sponsored nor endorsed by the Foxboro Company. All 
postings from this list are the work of list subscribers and no warranty 
is made or implied as to the accuracy of any information disseminated 
through this medium. By subscribing to this list you agree to hold the 
list sponsor(s) blameless for any and all mishaps which might occur due to 
your application of information received from this mailing list.

To be removed from this list, send mail to 
[EMAIL PROTECTED] 
with "unsubscribe foxboro" in the Subject. Or, send any mail to
[EMAIL PROTECTED]

Reply via email to