;LoginCapture.WAS     v1.0

;*****************************************************************************
;*                                                                           *
;* LoginCapture.WAS                                                          *
;* Copyright (C) 1998 Symantec                                               *
;* All rights reserved.                                                      *
;*                                                                           *
;* Written by:  Symantec ASPECT Assist                                       *
;* 04/23/98                                                                  *
;*                                                                           *                                                                             
;* This script file logs into a host system and captures data every half     *
;* hour.  Capture files are saved in the format hhmmDDMM.YY                  *
;*                                                                           *
;*                                                                           *
;* 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 Statements                                                        *
;****************************************************************************
#Define szHour       "00"              ;Define the top of the hour.  
#Define szHalf       "30"              ;Define the bottom of the hour.
#Define szDialNumber "8,15555555"      ;Number to dial. Can be changed. 
#Define szDialSuffix ",,,,,,###5"      ;Dial suffix. Can be changed or deleted.
#Define szPassword   "Password"        ;Password. Can be changed or deleted.
#Define szTempCap    "temp.cap"        ;Capture file name.
#Define szCapPath    "c:\temp"         ;Capture Path.
#Define szRepPath    "c:\temp"         ;Report Path.


;****************************************************************************
;* Main Procedure                                                           *
;****************************************************************************
proc main

   string  szMinutes

   CaptureData()                       ;Call the capture procedure. 
   pause 35
   yield
   while 1
      yield
      strextract szMinutes $time24 ":" 1 ;Get the time and save it.
      if stricmp szMinutes szHour        ;Wait for hour capture time.
         CaptureData ()                  ;Go to capture subroutine.
         yield
         pause 35
      else
         if stricmp szMinutes szHalf     ;Wait for half hour capture time.
            CaptureData ()               ;Go to capture subroutine.
            yield
            pause 35
         endif
      endif
      yield
   endwhile
endproc


;****************************************************************************
;* Capture Data Routine                                                     *
;**************************************************************************** 
proc CaptureData

   string szMonth, szDay, szYear, szHH, szMM, szFileName, szDialNum
   string szCapturePath = szCapPath, szReportPath = szRepPath
   string szTempCapPath
   
   set capture overwrite on              ;Overwrite the capture file. This file
                                         ;can be appended by setting this to OFF.
   strextract szMonth $DATE   "/" 0      ;Get info to make the filename.
   strextract szDay   $DATE   "/" 1
   strextract szYear  $DATE   "/" 2
   strextract szHH    $time24 ":" 0
   strextract szMM    $time24 ":" 1
   strfmt szMonth "%02.2s" szMonth
   strfmt szDay "%02.2s"   szDay
   strfmt szFileName "%s%s%s%s.%s" szHH szMM szDay szMonth szYear
   fetch capture path szTempCapPath      ;Get default capture path.
   set capture path szCapturePath        ;Assign temporary capture path.
   set capture file szTempCap            ;Assign the report a temporary name.
   strfmt szDialNum "%s%s" szDialNumber szDialSuffix
                                         ;Make the number to dial
   dialnumber data szDialNum             ;Dial the number
   pause 1
   while $dialing
      yield                              ;Yield processing time while dialing.
   endwhile
   set port databits 7                   ;Set the line settings.
   set port parity EVEN   
   pause 3
   transmit "^M"                         ;Send an enter.
   pause 1
   transmit "^M"
   waitfor "SSWORD:"                     ;Wait for Password Prompt.
   pause 2
   transmit szPassword                   ;Send the password if needed.
   pause 1
   transmit "^M"
   waitfor "@"                           ;Wait for special character. Can be
                                         ;removed if not needed.
   pause 1                               ;Wait for menu prompt.
   yield
   transmit "l r^M"                      ;Request a report.
   waitfor "SELECT REPORT"               ;Menu items and Waitfors can be edited.
   pause 3                               ;This section can edited to suit your
   transmit "4^M"                        ;particular host.
   waitfor "PATTERN"
   pause 3
   yield
   transmit "ALL^M"
   waitfor "RETURN"
   pause 1
   clear
   capture on                            ;Start capturing the data.
   transmit "^M"
   yield
   waitquiet 6 forever                   ;When the report is done.
   yield
   capture off                           ;Turn off the capture.
   transmit "c r^m"                      ;Clear the report on host.
   waitfor ":"
   pause 2
   transmit "3^m"
   waitfor "ELP):"
   pause 2
   transmit "all^M"
   waitfor "@"                           ;Wait for the next prompt.
   hangup                                ;Hang up the line.
   addfilename szCapturePath szTempCap
   addfilename szReportPath  szFileName
   rename szCapturePath szReportPath     ;Move capture file to report file.
   set capture path szTempCapPath        ;Reset capture path to default.
endproc