Posted: 08 Nov 2008 08:29 Last Edited By: sysaxsupport | ||
Registered User Currently Offline |
Posts: 9 Join Date: Nov 2008 |
|
#******************************************************************************
# # Script name: Oakhurst.fscr # # Description : Uploading items (files or folders) from local to remote host. # #****************************************************************************** # UPLOAD FILES # set the local and remote path strprint ~m_ul_remotepath, "oakhurst"; strprint ~m_ul_localpath, "C:\Campora\gas\DAT"; # Rule to handle duplicate files # Set the rules to use if a duplicate file already exists in the destination path. # The files may be compared by size or by date. # This is indicated by the keywords "bysize" or "bydate". # The following rule keywords may be specified: "resume", "rename" , "overwrite", and "skip". # resume if smaller, skip if same size or larger. setduperules bysize, resume, skip, skip; # Connection Mode : Passive mode transfers # Files may be transferred using server initiated (PORT) or client initiated (PASV) data connections. # The enablepasv command enables PASV data connections. enablepasv; # Connecting to remote hosts # Connections to a remote FTP server are established using the ftpconnect command. # The IP address of the remote server must be specified as the address string. # The port number indicates the port where FTP connections are accepted by the remote server. # The default port number for regular FTP connections is 21. # The username and password strings are required to log into a specific user account. ftpconnect("2", 21, "ftpuser", ""); # Set the desired local and remote paths # NOTE : "local" and "remote" are keywords used to denote the local and remote computers respectively. ftpsetpath local, ~m_ul_localpath; ftpsetpath remote, ~m_ul_remotepath; # List the contents of the local folder and all contents are store in a (@local_list) variable. # List the contents of the remote folder and all contents are store in a (@remote_list) variable. ftpgetlist local, @local_list; ftpgetlist remote, @remote_list; # For each item, check if it is a file. # NOTE: loop, if, and foreach statements must contain # enclosing "begin" and "end" blocks. # If statement check which local files are not in the remote folder, that files are # deleted from the remote folder using ftpdelete command. # Check if the ftpdelete command was successful. # If the delete was not successful, to check next file from the remote folder. foreach $rem_item in @remote_list begin foreach $loc_item in @local_list begin if $rem_item.name eq $loc_item.name begin setvar ~absent, "false"; end end if ~absent ne "false" begin ftpdelete remote, file, $rem_item.name; if ftpresult eq success begin print "DELETE FILE ",$rem_item.name," (because not present in local folder)"; end end setvar ~absent, "true"; end # The ftpwildcardmatch command can be used to perform wildcard matching. # Additionally, this command allows case insensitive pattern matching when i is passed as a match option. # If the strings match, the predefined flag ftpresult is set to the predefined constant success. # The ftpupload command used to upload the files from the local folder to the remote folder and set the # files name based on the user specified format. foreach $loc_item in @local_list begin foreach $rem_item in @remote_list begin if $loc_item.name eq $rem_item.name begin setvar ~present, "true"; if $loc_item.size != $rem_item.size begin ftpupload file, $loc_item.name; print "OVERWRITE TO FILE ",$loc_item.name," (because file size is not same)"; end end end if ~present ne "true" begin if $loc_item.isfolder eq false begin strprint ~filename_format, "*.dat"; ftpwildcardmatch $loc_item.name, ~filename_format, "i"; if success eq ftpresult begin ftpupload file, $loc_item.name; if ftpresult eq success begin print "UPLOAD FILE ",$loc_item.name," (because not present in remote folder)"; end end end end setvar ~present, "false"; end # send all messages to user specified emails mailcreate("campora","campora@campora.com","Oakhurst FTP","File transfer Results"); mailsend("mail.campora.com",25,"Curt Burgess","curt_burgess@hotmail.com","campora@campora.com",""); |
Posted: 08 Nov 2008 08:33 Last Edited By: sysaxsupport | ||
Moderator Currently Offline |
Posts: 367 Join Date: Nov 2008 |
|
You need to add an additional backslash when specifying the path. eg.
"C:\\Campora\\gas\\DAT" ------------------------------------------------------------------------- SSH FTP Server, Secure File Transfer, and Automated FTP |