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.
Need help writing a script? Have any question about ScriptFTP?
Hi Guys, new to this so bare with me. I am trying to check to see if a file is on a webserver and if it is, then upload another file. Problem is the time the file is uploaded from remote is random, so I need it to look for a file say: srequest.txt every minute and if found upload a file say: ssafe.txt right after that. Will Script FTP allow me to do this, and can anybody give me a idea as to what type of coding I should be using if it is to work with Script FTP. Any reply to this would be appreciated. Thanks..........
Hi all, I think that I have found the code that I think I need to use, in order for this to work for me below:

FTP Script
  1. # Settings
  2. $ftpserver="127.0.0.1"
  3. $ftpuser="user"
  4. $password="123456"
  5.  
  6. # Connect to FTP server
  7. OPENHOST($ftpserver,$ftpuser,$password)
  8.  
  9. # Enable passive mode (default)
  10. SETPASSIVE(ENABLED)
  11.  
  12. #Get list of remote file
  13. GETLIST($list,REMOTE_FILES,"*.*")
  14.  
  15.  
  16. # For each file in the remote directory
  17. # check if it matches "srequest.txt"
  18. $found="FALSE"
  19. FOREACH $filename IN $list
  20.         IF($filename =="srequest.txt")
  21.                 $found="TRUE"
  22.                
  23.         END IF
  24.  
  25. IF($found == "TRUE")
  26.         PUTFILE("ssafe.txt")       
  27.             STOP
  28.  
The problem is, I need this to run every minute, until it finds the file, and then start all over again on the hour and start again, until it finds the file.

And the other problem is how do I tell it to upload from a local folder from machine.

If anyone can tell me if this will work or if anyone has any other ideas as to how I can get this great. Thanks.
Hi,

You can use the ScriptFTP scheduler to run a script file every minute. I have made a screenshot to show you the sequence of windows you have to open to reach the place where this is set.
scheduled_ftp_script_windows.jpg
scheduled_ftp_script_windows.jpg (120.89KiB)Viewed 1901 times
mobile_save_distr.jpg
mobile_save_distr.jpg (95.03KiB)Viewed 1901 times


Another way to do that is to use the WHILE command. For example:
FTP Script
  1. $counter=0
  2.  
  3. # Run for five times
  4. WHILE($counter<5)
  5.  
  6.     $counter = $counter+1
  7.     # Place your own commands here
  8.  
  9.  
  10.     # Wait for a minute
  11.     SLEEP(60)
You can of course use a combination of the two methods
Why get the whole list and then look for your file?
FTP Script
  1. GETLIST($list,REMOTE_FILES,"srequest.txt")
  2. IF(COUNTELEMENTS($list) > 0)
  3.   PUTFILE("ssafe.txt")
  4.   STOP
Thanks to all the people who took the time to reply to my post. I have another question, is their a way for the script to inform me via email if their has been a problem or an error. Thanks.
Thanks Wandrey