Script Library

Sample scripts are provided as-is with no warranty of fitness for a particular purpose. These scripts are solely intended to demonstrate techniques for accomplishing common tasks. Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.


commercehub.s

Download

Robo-FTP provides all the functionality needed to implement a secure, reliable, automated connection to the CommerceHub® ONE Connection® Platform using FTP and PGP.

This sample script downloads new order files, decrypts using PGP, and renames the files (changing the .neworders extension to .xml).

See also:


  1  ;; enable log files
  2  LOG "commercehub.log"
  3  TRACELOG "commercehub_trace.log
  4  
  5  ;; local download destination folder
  6  WORKINGDIR "C:\Users\Public\Orders\ftp_downloads" 
  7  IFERROR RETURN
  8  
  9  ;; connect to commerce hub FTP managed site
 10  FTPLOGON "ftp1.commercehub.com" 
 11  IFERROR RETURN
 12  ;; CommerceHub will provide actual directory you should use
 13  FTPCD "company/outgoing/orders" 
 14  IFERROR RETURN
 15  ;; Download new orders. CommerceHub will delete them for you
 16  RCVFILE "*.neworders" 
 17  IFERROR RETURN
 18  :loop 
 19  ;; find name of next PGP file downloaded
 20  GETNEXTFILE "*.neworders" 
 21  IFERROR RETURN $ERROR_SUCCESS
 22  SETREPLACE NewFileName = %nextfile ".neworders" ".xml"
 23  ;; decrypt PGP file with NewFileName as output file name
 24  PGPDECRYPT %nextfile NewFileName
 25  IFERROR GOTO move_to_error
 26  MOVE NewFileName "C:\Users\Public\Orders"
 27  ;; remove downloaded PGP file
 28  DELETE %sitefile
 29  GOTO loop
 30  
 31  :move_to_error
 32  ;; couldn't decrypt file
 33  MOVE %nextfile "C:\Users\Public\Orders\ftp_downloads\errors"
 34  GOTO loop

Browse complete list of scripts