#!/usr/local/bin/tops -s /usr/local/tops/sys -u /opt/mytops/usr/

# File eod1, October 2004

# End of day collection of pit data

#-----------------------------------------------------------------------
    
   usrpath "mget.v" + source
   keys? not IF LOG-FILE set_sysout THEN

   ontheweb 
   host "riggo" = or
   IF " eod1: skipping pit end of day collection" . nl
      exit 
   THEN

   "/tmp" chdir

   inline: bcSAVE ( --- ) \ save bc data at end of day
      [ mpath time GMT>LA ctime 1st quote strchop
        sysdate drop intstr ".dat" cat cat "FILE" book
      ]
      " bcSAVE: begin " date + . nl
      bcEOD any? not
      IF 10 idle
         bcEOD any? not
         IF " bcSAVE: two attempts failed" ersys "" THEN
      THEN

      any?
      IF FILE file? IF FILE FILE ".old" + fcopy THEN
         (hT) FILE save " bcSAVE: file saved " date + . nl
      ELSE
         " bcSAVE: failed " date + . nl
      THEN
   end
   bcSAVE
  
   ontheweb not
   drop no
   IF tcCOLLECT "bcSAVE" "FILE" yank -ext "_tch.dat" + save
      " tcCOLLECT: file saved " date + . nl
   THEN
  
   ontheweb not
   IF no catmsg "snd.v" source 2 TING (qFile)
      (qFile) dup remote_wavPlayq 
      " eod1: playing sound file " . dup . sp date . nl
      (qFile) deleteif
   THEN

   " eod1: ending" . nl

   exit
