Posted: 07 Jan 2015 16:51 | ||
Registered User Currently Offline |
Posts: 5 Join Date: Jul 2009 |
|
Can you tell me how I can pass a command line variable to my script? I have a situation where I have 100 files that I need to FTP to a customer...some start with a prefix of COExxxx and some start with a prefix of BOSxxxx. These files may or may not all exist at the same time but the sequence is very critical as all BOS files must be FTPd first and then 1 hour later the COE files must be FTPd. I thought if I could pass a command line variable of either BOS or COE I could control which files I process in each time period. I realize I could make this 2 separate scripts but that causes lots of duplication of work in our scheduling system. Thanks |
Posted: 08 Jan 2015 15:18 | ||
Registered User Currently Offline |
Posts: 25 Join Date: Jul 2013 |
|
Hi Dan,
Here is a snippet of a script that should work for you. Since there is a waiting time of one hour, you should make sure that the account you are using has a timeout of seconds greater than 3600. setvar ~remote_itemname, "BOS*.*"; setvar ~remote_itemname2, "COE*.*"; #------------------------------------------------------------ # Set the action to take if a duplicate file with the same name already exists in the destination folder # Syntax: setduperules <keywords: bysize, bydate>, <action if smaller/older>, <action if same size/date>, <action if larger/newer> [, optional: <rename ext string>]; setduperules bysize, overwrite, overwrite, overwrite; # Establish a regular FTP connection with the remote server # Syntax: ftpconnect <address string>, <port number>, <username>, <password> [, optional: <account>]; ftpconnect ~server_address, ~server_port, ~login_name, ~login_password; if ftpresult eq success begin # Successfully connected to remote server stringjoin ~connect_success_message, "Successfully connected to remote server at ", ~server_address, " on port ", ~server_port, " for user ", ~login_name; print ~connect_success_message; # Set the local and remote paths ftpsetpath local, ~local_path; ftpsetpath remote, ~remote_path; # Download the file from the remote server # Syntax: ftpdownload <keywords: file, folder>, <remote name string> [, optional: <local name string>]; ftpdownload file, ~remote_itemname; waitsecs 3600; ftpdownload file, ~remote_itemname2; Regards, Sysax Support |
Posted: 08 Jan 2015 16:01 | ||
Registered User Currently Offline |
Posts: 5 Join Date: Jul 2009 |
|
Thanks for the response. I can see how that would work but I am hesitant to have a task be active for 1 hour just counting seconds. The other condition that could exist is that the second set of files may not actually be ready one hour later. My hope was that I could have our master scheduling system submit a command line parameter that would tell the sysax script which file to process. Thanks |
Posted: 08 Jan 2015 20:14 | ||
Registered User Currently Offline |
Posts: 25 Join Date: Jul 2013 |
|
Hi Dan, the scripting manual can be found on the drive where the Sysax FTP Automation Suite is installed. On Windows 7, it is located here - file:///C:/Program%20Files/SysaxAutomation/doc/html/ftpscript/index.html
Chapter 3 might have the help that you are looking for, especially the ftpgetlist command. If you are still in need of help, please file a ticket so that we can help you offline. You can submit a ticket here - https://www.sysax.com/support/ Regards, Sysax support |
Posted: 16 Jan 2015 18:42 | ||
Registered User Currently Offline |
Posts: 5 Join Date: Jul 2009 |
|
copy/paste from Sysax Support email. This worked perfectly.
In any case, to answer your original question, yes you can pass command line variables to the script. This involves 2 parts. As John U. mentioned, you can use the -set option in the command line. The important thing to note here is that the format needs to be -set MYVARIABLE="value" You should not have the ~ symbol in front of the variable. The second part is actually reading the value of the variable from the script. This is done using the getenvvar command like this, from within your script: getenvvar ~myvalue, "MYVARIABLE"; This will set the value of ~myvalue to what was passed from the command line. |
Posted: 19 Jan 2015 15:08 | ||
Registered User Currently Offline |
Posts: 25 Join Date: Jul 2013 |
|
Hi Dan,
Thank you for adding your comments to the forum, which may assist others in their scripting. I'm glad that you have the answer that you were looking for. Regards, Sysax support |