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?
I am looking for a solution to run a batch file from a Machine A that is on the same wireless network as Machine B, such that:

1. The program will know the current DATE and TIME when the FTP request is initiated.
2. Will go onto Machine B, into the folder for that date (ie the file structure has folders based on date on Machine B)
3. In the current dates folder, will grab files recorded five minutes prior to the FTP initiation (ie the saved files have a time stamp in them), and upload them over the internet to Remote Server C.
4. Will then grab files recorded immediately AFTER the ones five mins prior to FTP initiation, and upload those to Remote Server C, and so forth, until the FTP is told to stop by user input.

Here is the file structure showing the different files (and the dates and times) on Machine B, that I would like to be able to upload to a remote server at the press of a button, with the FTP knowing my current date and time and knowing that what I want are all the files that recorded events from 5 minutes ago, and then onward into the present, uploaded to the remote server in that order.

Essentially I want to hit a button and have this all done without me having to navigate through all the file structures, and such.

07/04/2012 12:46PM 75,366,400 000000010000000B-120704-123138-124638-12p408000000.264 07/04/2012 01:01PM 77,332,480 000000010000000B-120704-124638-130138-12p408000000.264 07/04/2012 01:16PM 76,742,656 000000010000000B-120704-130138-131638-12p408000000.264 07/04/2012 01:31PM 74,907,648 000000010000000B-120704-131638-133138-12p408000000.264 07/04/2012 01:36PM 25,493,504 000000010000000B-120704-133138-133643-12p408000000.264 07/04/2012 02:31PM 64,487,424 000000010000000B-120704-141648-141648-12p408000000.264 07/04/2012 12:31PM 78,839,808 000000010000000F-120704-121638-123138-12p406000000.264 07/04/2012 12:46PM 68,485,120 000000010000000F-120704-123138-124638-12p406000000.264 07/04/2012 01:01PM 74,645,504 000000010000000F-120704-124638-130138-12p406000000.264 07/04/2012 01:16PM 78,643,200 000000010000000F-120704-130138-131638-12p406000000.264 07/04/2012 01:31PM 78,381,056 000000010000000F-120704-131638-133138-12p406000000.264 07/04/2012 01:36PM 26,607,616 000000010000000F-120704-133138-133643-12p406000000.264 07/04/2012 02:31PM 67,436,544 000000010000000F-120704-141648-141648-12p406000000.264 07/04/2012 12:31PM 79,101,952 000000010000000I-120704-121638-123138-12p402000000.264 07/04/2012 12:46PM 69,337,088 000000010000000I-120704-123138-124638-12p402000000.264 07/04/2012 01:01PM 77,070,336 000000010000000I-120704-124638-130138-12p402000000.264 07/04/2012 01:16PM 71,696,384 000000010000000I-120704-130138-131638-12p402000000.264 07/04/2012 01:31PM 67,436,544 000000010000000I-120704-131638-133138-12p402000000.264 07/04/2012 01:36PM 23,330,816 000000010000000I-120704-133138-133643-12p402000000.264 07/04/2012 02:31PM 57,212,928 000000010000000I-120704-141648-141648-12p402000000.264 07/04/2012 12:31PM 75,300,864 000000010000000L-120704-121638-123138-12p405000000.264 07/04/2012 12:46PM 71,368,704 000000010000000L-120704-123138-124638-12p405000000.264 07/04/2012 01:01PM 74,252,288 000000010000000L-120704-124638-130138-12p405000000.264 07/04/2012 01:16PM 75,366,400 000000010000000L-120704-130138-131638-12p405000000.264

You can see the file name includes an identifier for file type (L,I,F,B) and then a date stamp, and then a time range (130138-131638) and then some other info in the filename that isn\'t important. Can the batch program use regular expressions to find the right files and upload them to the Remote Server after grabbing the current system Date & Time? Thanks for your time.
Hello,

I am sorry but ScriptFTP is not able to deal with regular expressions. However I can give you some clues about how you can achieve most of the steps of the process you posted:
1. The program will know the current DATE and TIME when the FTP request is initiated.
You can get this value calling GETTIME()
FTP Script
  1. $current_date_and_time = GETTIME(FORMAT2)
2. Will go onto Machine B, into the folder for that date (ie the file structure has folders based on date on Machine B)
If, for example, the current date is July the 7th 2012 and the corresponding folder name is 20120722 you can go to that dir this way:
FTP Script
  1. $folder_name = GETDATE(FORMAT3)
  2. CHDIR($folder_name)
If the date is arranged in a different way you can buid the folder name retrieving the current month, day and year separately:
FTP Script
  1. $month=GETTIME(MONTH)
  2. $year=GETTIME(YEAR)
  3. $day=GETTIME(DAY)
  4.  
  5. $folder_name = $month.$year.$day
  6.  
  7. CHDIR($folder_name)
3. In the current dates folder, will grab files recorded five minutes prior to the FTP initiation (ie the saved files have a time stamp in them), and upload them over the internet to Remote Server C.
This is a bit more difficult to do:
FTP Script
  1. OPENHOST("127.0.0.1","test","test")
  2.  
  3. $current_date_and_time= GETTIME()
  4. $current_date_and_time_adjusted_to_server_time_zone = $current_date_and_time - (60*60*2)
  5.  
  6. $five_minutes_ago = $current_date_and_time_adjusted_to_server_time_zone - (60*5)
  7.  
  8. PRINT("")
  9. PRINT("Five minutes ago adjusted to the server local time which is what GETFILETIME reports is:")
  10. PRINT($current_date_and_time_adjusted_to_server_time_zone )
  11.  
  12. GETLIST($list,REMOTE_FILES)
  13.  
  14. FOREACH $file IN $list
  15.  
  16.     $file_last_modifiaction_time = GETFILETIME(REMOTE,$file)
  17.  
  18.     PRINT("This file was last modified at: ".$file_last_modifiaction_time)
  19.  
  20.     IF($file_last_modifiaction_time > $five_minutes_ago)
  21.         GETFILE($file)
  22.     END IF 
  23.  
  24.  
  25.  
4. Will then grab files recorded immediately AFTER the ones five mins prior to FTP initiation, and upload those to Remote Server C, and so forth, until the FTP is told to stop by user input.
This will be very similar to the other script. Instead of calculating the date and time from five minutes ago you have to calculate it five minutes ahead. Adding seconds instead of substracting.