ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Missing any feature or command? Post your ideas here. Suggestions are welcome.
Hi,

Might just have not ween the feature anywhere.

Is there a way to have a master scripts that loads multiple .ftp script

Ex:
Master.ftp
- Load myfirst.ftp
- Load mysecond.ftp
- etc

And is there a way to Read/Write to .txt files.
Reaosn I want to do this is to be able to check in a directory the latest file and push it to a server then write to a file that that files has been push (since I have to change the file name I can't use the sync function)
Then when ever the scirpt runs It loads the file and check if the newest file in the directory has been pushed to the server.

Now combining both questions I could have a .txt files that contains all different username/pass/ip and 1 script that reads the file does a for loop with each line and write the file using the username.

Just asking if its feasable...

Thanks for the great product :)
Hi,

You can actually run a script file within another script using the EXEC command to call ScriptFTP_console.exe (the command line version of ScriptFTP).

It is done this way:

FTP Script
  1. # Beware the weird use of the quotation marks.
  2. # There are single quotes (') and double quotes ("). This is
  3. # necessary because we are using paths with spaces between words. More info here:
  4. # https://www.scriptftp.com/d/ftp-miscellaneous-commands/exec
  5. EXEC('"C:\Program Files (x86)\ScriptFTP\ScriptFTP_console.exe" "C:\Users\Carlos\Desktop\unnamed.ftp"')
The problem is that you will get the output of the script not correctly displayed. See the attached screenshot.


Regarding the seconds question, yes, this is something that some users have already requested. There is a workaround which also uses EXEC:

FTP Script
  1. # The text we want to write to a text file
  2. $my_text = "hello world!"
  3.  
  4. # Run echo hello world > "C:\Users\Carlos\Desktop\test.txt" as if we have
  5. # open the Windows Command Promp
  6. EXEC('echo '.$my_text.' > "C:\Users\Carlos\Desktop\test.txt"')
Now combining both questions I could have a .txt files that contains all different username/pass/ip and 1 script that reads the file does a for loop with each line and write the file using the username.
Doing that is out of the scope of ScriptFTP becase to support this it would be required to add commands to properly handle text files, arrays may be regular expressions to separate the username/pass/ip fields in one line...

A while ago there was a user who dinamically generated scripts for ScriptFTP using Visual Basic or something similar.
Attachments
run_script_within_a_script.jpg
run_script_within_a_script.jpg (243.86KiB)Viewed 6503 times
Just a small update to my last post.

The ScriptFTP 4.5 beta version available at https://www.ScriptFTP.com/beta correctly shows the output of the EXEC command (see the garbled output in the screenshot of the previous post). This was a bug of the EXEC command that has been just fixed.
In regards to calling your script within a script -

I run a system in AWS that connects to customers' firewalls/routers, and downloads logging data (Public WiFi) and configurations (on pfSense) I run one master script that calls subscripts for each customer. This is a snapshot from my master script -

So for each customer, in the master script, I list them as a variable, and give them the number 1 to run, or 0 to skip. (Some customers shutdown their holiday parks etc over winter)

If the customer is active, I call the sync script, and I pass to it, Today's date to exclude that folder for download, Yesterday's date to exclude that folder for download, the date 5 days ago (I only keed 5 day's worth of logs on the firewalls), the name, An appropriate number of #'s is the next variable, as I output PDF's of each individual customers' download for that night, this is part of the title, the next field is a password, which seems like a security problem, when in fact, I only had access to 3.x versions of ScriptFTP at the time, so I actually call a SSH>FTP tunnel on the AWS host, so the passwords to the firewalls etc are actually secure on the AWS server, then I tell the sync script how many WAN connections the firewall has, so that it can connect to WAN2 etc if WAN1 is down. Lastly, I tell the sync script what type of firewall it's connecting to, as the pfSense loop also downloads the configuration of the firewall.
FTP Script
  1. IF($xxxxx==1)
  2.     $run_script=EXEC('"C:\Program Files (x86)\ScriptFTP\scriptftp.exe" "D:\configuration\ftp scripts\Sync.ftp" ".$TodayDate.'" "'.$YesterdayDate.'" ".$FiveDays.'" "XXXXX" ################ %nQhZhVu$w 2 PFSENSE')
  3.     IF($run_script==2)
  4.         PRINT("XXXXX - FAILED")
  5.         EXEC('D:Wonfiguration\file_writer.exe append failed "XXXXX"')
  6.     ELSE
  7.         PRINT("XXXXX - Successfully Downloaded")
  8.         EXEC('D:\Configuration\file_writer.exe append active "XXXXX"')
  9.     END IF
  10.     PRINT("XXXXX - Skipped")
  11.     EXEC('D:Wonfiguration\file_writenexe append skipped "XXXXX"')
I run a piece of custom software above too called "file_writer.exe" written in AutoIT, I actually call about 6 different little AutoIT programs during the run.

At the end of my script I get an e-mail sent to me with a list of firewalls that have successfully downloaded, any failed downloads and lastly skipped firewalls. With individual logs attached in .pdf to the email.

Regarding your question about reading filenames, users passwords etc, then you could do it within AutoIT, get AutoIT to generate your .ftp file "on the fly" and execute it.
Thanks for posting such a detailed information in the forum. I am sure this will be useful for other people.

I have updated your post with the script code etc. Yes, this forum runs behind a very restrictive HTTPS firewall and anti spam rules. It is the only way to prevent some people to post spam... sorry for that