;* Batch file upload to FTP host.

;*****************************************************************************
;* Written by:  Symantec ASPECT Assist                                       *
;*                                                                           *                                                                             
;* This script file will give the user the option of either capturing data   *
;* in half hour increments, or in 24 hour increments. The Capture file will  *
;* close after a predefined period of inactivity on the port.                *
;*                                                                           *
;* 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.                         *                                                                          *
;*****************************************************************************


;*****************************************************************************
;*                                                                           *
;* MAIN                                                                      *
;*                                                                           *
;* Creates a file containing a list of the files in the Procomm Plus upload  *
;* directory and then reads the file, uploading the files referenced one at  *
;* a time.                                                                   *
;*                                                                           *
;*****************************************************************************

proc main
   string UploadDirectory		;path for file upload
   string FilesToGo	        	;list of files to upload
   string FileToFTP	        	;filename w/o PATH FTP transfer
   string PathToGo,FileBuild
     
   fetch upldpath UploadDirectory       ;get default upload path
   ftp LOCAL CHDIR UploadDirectory      ;change to that directory locally
   PathToGo = UploadDirectory
   FilesToGo = "filestogo.txt"          ;will be in ASPECT directory
   addfilename PathToGo "*.*" 
         	   	
   if isfile FilesToGo		        ;if file exists, delete it
      delfile FilesToGo
   endif
   
; Use DOS DIR command to read the default upload path and create a file which
; contains a list of the files found.  Note that the use of quotes around the
; path name allows you to circumvent the DOS path/file name limitations.
                                           
   strfmt FileBuild "`"dir `"%s`" /b > `"%s`"`"" PathToGo FilesToGo

   DOS FileBuild HIDDEN                 ;create file of directory
   pause 5				;allow enough time to build the file

   if isfile FilesToGo		        ;make sure file exists
      fopen 0 FilesToGo READ TEXT	;open upload file list
      
      while not feof 0			;loop to end of file
	 fgets 0 FileToFTP		;get line from file
	    ftp LOCAL COPYFILE FileToFTP     ;upload the file
	    while $ftpstatus
	       yield
	    endwhile
      endwhile
      fclose 0  
                  		;close the file
   else
      usermsg "%s not found.  Script aborted." FilesToGo
      
   endif

   delfile FilesToGo                    ;delete temp file        

endproc

