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?
Is there a way to get elapsed time? I have tried:
FTP Script
  1. $StartTimestamp = GETTIME(FORMAT0)
  2. Print("Elapsed ".(GETTIME(FORMAT0) - $StartTimestamp))
But it just prints 0
Hello Bucket,

No way, sorry. The minus (-) operator only allow to substract seconds for a given date. Not calculate the difference between them. For example:
FTP Script
  1. # Get the current date in the format AAAA_MM_DD-hh_mm_ss
  2. $currentdate=GETDATE(FORMAT0)
  3.  
  4. # Then, you can substract or add seconds to that date stored
  5. # in the variable. Yesterday is:
  6. $yesterday=$currentdate-(60*60*24)
  7. # (3600*60*60) is the amount in seconds in a day.
  8.  
  9. # This shold print the yesterday date:
  10. PRINT($yesterday)
I hate taking no for an answer...
FTP Script
  1. #coordinate with :aPrintElapsed routine
  2.     $StartTimestamp=GETTIME(HOUR).GETTIME(MIN).GETTIME(SEC)
  3.  
  4.  
  5.  
  6.     goto :aPrintElapsed
  7. :ReturnElapsed
  8.  
  9.  
  10.  
  11. # ########################################################
  12. # ########################################################
  13.  
  14. :aPrintElapsed
  15.     #HHMMSS
  16.     #123456
  17.     $startSeconds =  (textcut($StartTimestamp,1,2) * (60 * 60)) + (textcut($StartTimestamp,3,2) * (60)) + textcut($StartTimestamp,5,2)
  18.  
  19.     #endSeconds
  20.     $endTimeStamp = GETTIME(HOUR).GETTIME(MIN).GETTIME(SEC)
  21.     $endSeconds =  (textcut($endTimeStamp,1,2) * (60 * 60)) + (textcut($endTimeStamp,3,2) * (60)) + textcut($endTimeStamp,5,2)
  22.  
  23.     Print("Elapsed ".($endSeconds - $startSeconds))
  24.  
  25. goto :ReturnElapsed
wow
It should be noted that the result will be less than 0 if the elapsed time falls over a day (0 hours being less than 23 hours). But that can be tested for and adjusted if it is important enough.
Due to some esoteric timing issues (see Timing Issues in the Bugs forum), the scriplet has changed to:
FTP Script
  1. :PrintElapsed
  2.     #YYYY_MM_DD-hh_mm_ss : GETTIME(FORMAT0)
  3.     #1234567890123456789
  4.     #         1
  5.     $startSeconds =  (textcut($StartTimestamp,12,2) * (60 * 60)) + (textcut($StartTimestamp,15,2) * (60)) + textcut($StartTimestamp,18,2)
  6.  
  7.     #endSeconds
  8.     $endTimeStamp = GETTIME(FORMAT0)
  9.     $endSeconds =  (textcut($endTimeStamp,12,2) * (60 * 60)) + (textcut($endTimeStamp,15,2) * (60)) + textcut($endTimeStamp,18,2)
  10.    
  11.     $elapsedSeconds = $endSeconds - $startSeconds
  12.  
  13.     Print("Elapsed ".$elapsedSeconds." seconds")
  14.  
  15. goto :ReturnElapsed
This in one hell of a code and worth to be put in the hall of fame. Thanks.
:D