Logging ScriptFTP output
The LOGTO command is used to log ScriptFTP output to a text file. After calling this command, every message shown on the ScriptFTP window will be added to the specified text file (log file). With this feature you can check if your scheduled job has been carried out correctly.
Let us look at an example:
# Log output to C:\transfer_log.txt LOGTO("C:\transfer_log.txt") # Connect to server OPENHOST("ftp.host.com","myuser","mypassword") # Download some files GETFILE("ClientDocs/*.*",SUBDIRS) # Close connection CLOSEHOST() # Close ScriptFTP. The script output is saved # to the log file so we do not need to keep the # ScriptFTP window opened. EXIT
In the above example ScriptFTP overwrites the log file each time it is executed. If you want to keep the history of subsequent runs you may append the current date to the log file name:
# Build the log file name and path using the current date $log_file_name="C:\log_file_name-".GETDATE(FORMAT2).".txt" # Log script output LOGTO($log_file_name) # Connect to server OPENHOST("ftp.host.com","myuser","mypassword") # Download some files GETFILE("ClientDocs/*.*",SUBDIRS) # Close connection CLOSEHOST() # Close ScriptFTP. The script output is saved # to the log file so we do not need to keep the # ScriptFTP window opened. EXIT
You may also supply the optional parameter APPEND to the LOGTO command. Thus ScriptFTP will append its output to the log file each time the script is executed:
# Log output to C:\transfer_log.txt LOGTO("C:\transfer_log.txt",APPEND) # Connect to server OPENHOST("ftp.host.com","myuser","mypassword") # Download some files GETFILE("ClientDocs/*.*",SUBDIRS) # Close connection CLOSEHOST() # Close ScriptFTP. The script output is saved # to the log file so we do not need to keep the # ScriptFTP window opened. EXIT
As a hint, if you find the script’s output too detailed use the SILENT command to have ScriptFTP display the essential information only.