;Kermit_Upload.WAS     v1.0

;*****************************************************************************
;*                                                                           *
;* Kermit_Upload.WAS                                                         *
;* Copyright (C) 1998 Symantec                                               *
;* All rights reserved.                                                      *
;*                                                                           *
;* Written by:  Symantec ASPECT Assist                                       *
;* 01/30/98                                                                  *
;*                                                                           *                                                                             
;* Kermit_Upload establishes a direct connection through a serial port to    *
;* a Host system, and then uploads a file using Kermit protocol.  The        *
;* directory where the file is uploaded from is defined within the script.   *
;*                                                                           *
;* 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 fFILEPATH "C:\Test\"                ;The directory to watch for files.
#define szFILESPEC "*.*"                    ;The wildcard to use.
#define iCOMPORT 2                          ;Set the comm port to use.

;*****************************************************************************
; Main                                                                       *
;*****************************************************************************
Proc Main

   StartProcess()                           ;Calls procedure to start the process.
endproc


;*****************************************************************************
; StartProcess                                                               *
;*****************************************************************************
Proc StartProcess

   string szFileName

   FindFile(&szFileName)                    ;Finds the filename in directory.
   SetConnection()                          ;Sets the connection/login.
   SendTheFile(szFileName)                  ;Sends the file.
   Finished()                               ;Closes connection & exits Procomm.
endproc


;*****************************************************************************
; FindFile                                                                   *
;*****************************************************************************
Proc FindFile
param string szFileName

   string szSearch

   szSearch = fFILEPATH                     ;Get file path to search for file.
   strcat szSearch szFILESPEC               ;Add the wildcard to path.
   if findfirst szSearch                    ;Find first file matching spec.
      szFileName = $filespec                ;Get the full filename.
   else
      errormsg "No file to send in '%s' directory!`r`nThe Script will end." fFILEPATH
      pwexit                                ;Close Procomm Plus.
   endif
endproc


;*****************************************************************************
; SetConnection                                                              *
;*****************************************************************************
Proc SetConnection

   set modem connection iCOMPORT            ;Set direct connect connection.
   pause 1
   yield

;Set Line settings

   set port baudrate 9600                   ;Set the connection to 9600 baud.
   set port parity NONE                     ;Set connection for N81
   set port databits 8
   set port stopbits 1
   
   transmit "^M"                            ;Send a Carriage Return.
   mspause 500
   transmit "^[chd arl^M"                   ;Send first command.
   mspause 500
   transmit "ker^M"                         ;Send second command.
   mspause 500
   transmit "server^M"                      ;Send third command.
   mspause 500
   transmit "^M"                            ;Send a Carriage Return.
endproc


;*****************************************************************************
; SendTheFile                                                                *
;*****************************************************************************
Proc SendTheFile
param string szFileName

   sendfile KERMIT szFileName               ;Send the file with Kermit.
   mspause 500
   while $xferstatus                        ;Loop while sending file.
      yield
   endwhile
endproc


;*****************************************************************************
; Finished                                                                   *
;*****************************************************************************
Proc Finished

   pause 1
   hangup                                   ;Close the connection.
   pause 1
   yield
   pwexit                                   ;Exit Procomm Plus.
endproc
