;CaptureFTP.WAS     v1.0

;*****************************************************************************
;*                                                                           *
;* CaptureFTP.WAS                                                            *
;* Copyright (C) 1998 Symantec                                               *
;* All rights reserved.                                                      *
;*                                                                           *
;* Written by:  Symantec ASPECT Assist                                       *
;* 08/24/98                                                                  *
;*                                                                           *                                                                             
;* This script file captures data to a file from a comm port, and then       *
;* uses the FTP client to send the file to a remote system via FTP           *
;* A time can be specified to start the capture file.                        *
;*                                                                           *
;* This ASPECT script is intended only as a sample of ASPECT programming.    *
;* Symantec makes no warranty of any kind, express or implied, including     *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*                                                                           *
;* Technical Support is not provided on this script.                         *                                                                          *
;*****************************************************************************


;*******************************************************************************
;* Define                                                                      * 
;*******************************************************************************
#define szSTARTTIME "03:00:00"           ;The start time for capture files.
#define szPATH "c:\temp\"                ;The capture path directory.
#define iQUITTIME 15                     ;The inactivity time to wait for data.
#define szEXT ".DAT"                     ;The file extension for cap file.
#define szFTP "Symantec"                 ;The FTP Connection Directory entry to 
                                         ;upload file

;*******************************************************************************
;* MAIN                                                                        * 
;*******************************************************************************
proc main

   StartProcess()                        ;Call the StartProcess Procedure.
endproc


;*******************************************************************************
;* StartProcess                                                                * 
;*******************************************************************************
proc StartProcess

   string szTime                         ;String variable to hold the system time. 
   
   while 1                               ;Loop forever.
      szTime = $time24                   ;Get the system time in 24 hour format.
      if stricmp szSTARTTIME szTime      ;Compare system time with start time
                                         ;and if they are the same...
         StartIt()                       ;Call the StartIt Procedure.
      else
         yield                           ;Yield processor time while looping.
      endif
   endwhile
endproc


;*******************************************************************************
;* StartIt                                                                     * 
;*******************************************************************************
proc StartIt

   string szFile, szTemp                 ;String variables to hold file names.

   set modem connection 1                ;Set the connection.
   
   strextract szFile $date "/" 0         ;Get the year.
   strextract szTemp $date "/" 1         ;Get the month.
   strcat szFile szTemp                  ;Put year and month together and store
                                         ;it in the szFile variable.
   strextract szTemp $date "/" 2         ;Get the day and put it in szTemp.
   strcat szFile szTemp                  ;Combine the day with the szFile variable
                                         ;and store it back in szFile.
   strcat szFile szEXT                   ;Put the file extension at the end of 
                                         ;the file name stored in szFile.
   
   set capture path szPATH               ;Set the path to store the capture file.
   set capture file szFile               ;Name the capture file with whatever is in
                                         ;the szFile variable.
   capture on                            ;Turn the capture on
   waitquiet iQUITTIME FOREVER           ;Wait for the length of time specified
                                         ;in iQUITTIME.
   capture off                           ;Turn the capture off.
   
   FTPIt(szFile)                         ;Call FTPIt procedure
      
endproc

;*******************************************************************************
;* FTPIt                                                                       * 
;*******************************************************************************

proc FTPIt
param string szFile

   PWMode FTP
   pause 3

   FTP LOCAL CHDIR szPath                      ;Set the local dir. to capture path.
   pause 1
   Connect FTP szFTP                           ;Connect to specified FTP site.
   pause 2
   while $ftpstatus
      yield                                    ;Loop while connecting to FTP site.
   endwhile
   pause 1                                     ;Let Procomm update its screen.
   
   FTP LOCAL COPYFILE szFile                   ;Copy (upload) file to FTP site.
   while $ftpstatus                            ;Yield while transferring file.
      yield
   endwhile
   disconnect
   pause 3
   pwmode TERMINAL
   pause 3
endproc
