Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

handling_errors_3.ftp

This script uses WHILE to check if the result of OPENHOST was OK. If not tries to reconnect. Note that OPENHOST will be called indefinitely while the connection does not succeed.

# The While sentence here means "Run OPENHOST while its
# result is different than OK". If OPENHOST fails it
# will be executed again and again.
 
WHILE($result_open_host!="OK")
 # Note that in the first loop the value of
 # the variable $result_open_host is an empty text string so
 # it is different than OK
 
 # Connect to ftp.myhost.com and save the result in the variable
 # result_open_host.
 $result_open_host=OPENHOST("ftp.myhost.com","myuser","123456")
END WHILE
 
 
# If this point is reached means that ScriptFTP is
# already connected
 
# Upload the files
PUTFILE("sales.xls")
PUTFILE("backup.zip")
PUTFILE("notes.txt")
PUTFILE("1.jpg")
 
# Close the connection 
CLOSEHOST