Reply To: FTP file to Cloverleaf

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf FTP file to Cloverleaf Reply To: FTP file to Cloverleaf

#59768
Russ Ross
Participant

    I like to do what Glen suggested and pull the files across via FTP/get.

    You could use the FTP protocol built in the engine and have cron start the Cloverleaf process and/or threads.

    I typically use a k-shell script invoked by cron to do FTP/gets.

    The same k-shell scripting concept is also applicable to OpenSSH SFTP/gets.

    My entire FTP/get script might have a distracting amount of other bells and whistles so here is a k-shell code snippet to illustrate just the FTP/get part

    Code:

    ftp -inv <<- ! >> $local_ftp_log_file
       open $host_name
       user $user_id $pass_word
       $transfer_mode
       cd $remote_dir
       pwd
       dir
       lcd $local_dir
       mget $remote_file
       bye
    !

    Once you have determined the file(s) have been pulled across successfully then you mihgt want to do an FTP/delete to clear them off the source system, so here is an example of that k-shell code snippet

    Code:

    ftp -inv <<- ! >> $local_ftp_log_file
       open $host_name
       user $user_id $pass_word
       cd $remote_dir
       pwd
       dir
       mdelete $remote_file
       pwd
       dir
       bye
    !

    I warn you against assuming FTP is fool proof and advise you put methods in place to make sure your files are delivered and not lost or truncated.

    The simplest way is to check for a trailer record in the file that at least tells you how many records are in the file and confirm they match.

    Since people often hand edit FTP files, I even do some basic data validation of the files when possible.

    Given my preference, I would have the source system create a companion check sum file that would be used to make sure the file was complete and had not been tampered with.

    Russ Ross
    RussRoss318@gmail.com