Hello,
I try to get in sync two servers with scriptftp, both servers have the same date and time setting (GMT+1, synchronized with time.windows.com). When I get a remote file date using GETFILETIME(REMOTE,"filename.ext") the returned date and time is shifted with ~-3600 seconds (1 hour)! This is strange because when I connect to the remote server with Filezilla client the returned date and time for the same file is correct (+1 hour)?
I could try to define the difference with the SETCLOCKDIFF command but I do not know the exact shift time between both servers. Currently my workaround is to add 3600 to the GETFILETIME command. I would like to know if I can recall the time difference between both servers with scriptftp? The SYNC command is able to detect the difference but I would like to use the GETFILETIME command because I have to parse a file list using GETLIST and move files depending on their date and time to different folders.
Thanks
Gilles
I try to get in sync two servers with scriptftp, both servers have the same date and time setting (GMT+1, synchronized with time.windows.com). When I get a remote file date using GETFILETIME(REMOTE,"filename.ext") the returned date and time is shifted with ~-3600 seconds (1 hour)! This is strange because when I connect to the remote server with Filezilla client the returned date and time for the same file is correct (+1 hour)?
I could try to define the difference with the SETCLOCKDIFF command but I do not know the exact shift time between both servers. Currently my workaround is to add 3600 to the GETFILETIME command. I would like to know if I can recall the time difference between both servers with scriptftp? The SYNC command is able to detect the difference but I would like to use the GETFILETIME command because I have to parse a file list using GETLIST and move files depending on their date and time to different folders.
Thanks
Gilles
My new idea is to mimic the SYNC time shift computing. Below my script
[scriptftp="calculate_time_difference_between_servers.gtp"]$result=PUTFILE('timestampspy.txt')
IF($result=='OK')
$result=GETFILE('timestampspy.txt')
IF($result=='OK')
$localtime=GETFILETIME(LOCAL,'timestampspy.txt')
$remotetime=GETFILETIME(REMOTE,'timestampspy.txt')
$timediff=$localtime - $remotetime
END IF
END IF
IF($result!='OK')
$timediff=3600
END IF
PRINT('local : '.$localtime)
PRINT('remote : '.$remotetime)
PRINT('diff : '.$timediff)[/ScriptFTP]
and below the display result:
Thanks
Gilles
[scriptftp="calculate_time_difference_between_servers.gtp"]$result=PUTFILE('timestampspy.txt')
IF($result=='OK')
$result=GETFILE('timestampspy.txt')
IF($result=='OK')
$localtime=GETFILETIME(LOCAL,'timestampspy.txt')
$remotetime=GETFILETIME(REMOTE,'timestampspy.txt')
$timediff=$localtime - $remotetime
END IF
END IF
IF($result!='OK')
$timediff=3600
END IF
PRINT('local : '.$localtime)
PRINT('remote : '.$remotetime)
PRINT('diff : '.$timediff)[/ScriptFTP]
and below the display result:
PUTFILE("timestampspy.txt")As you can see it the $timediff var is not computed and return 0!? How can I correctly compute a diff date please?
Uploading................. timestampspy.txt
GETFILE("timestampspy.txt")
Downloading................. timestampspy.txt
GETFILETIME(LOCAL,"timestampspy.txt")
GETFILETIME(REMOTE,"timestampspy.txt")
local : 2011_03_21-18_50_29
remote : 2011_03_21-17_50_41
diff : 0
Thanks
Gilles
Hello,
A new day and another solution! Now, I'm able to compute the diff time betwen server, but it was not so simple to do. Here the script
[scriptftp="calculate_time_difference_between_servers_v2.ftp"]$result=PUTFILE('timestampspy.txt')
IF($result=='OK')
$result=GETFILE('timestampspy.txt')
IF($result=='OK')
$localtime=GETFILETIME(LOCAL,'timestampspy.txt')
$remotetime=GETFILETIME(REMOTE,'timestampspy.txt')
$localday=((TEXTCUT($localtime,1,4)-1980)*12*30)+(TEXTCUT($localtime,6,2)*12)+(TEXTCUT($localtime,9,2)*30)
$localsec=(TEXTCUT($localtime,12,2)*60*60)+(TEXTCUT($localtime,15,2)*60)+TEXTCUT($localtime,18,2)
$remoteday=((TEXTCUT($remotetime,1,4)-1980)*12*30)+(TEXTCUT($remotetime,6,2)*12)+(TEXTCUT($remotetime,9,2)*30)
$remotesec=(TEXTCUT($remotetime,12,2)*60*60)+(TEXTCUT($remotetime,15,2)*60)+TEXTCUT($remotetime,18,2)
$diffdaysec=(($localday-$remoteday)*24*60*60)
IF($localsec>$remotesec)
$diffsec=($localsec+$diffdaysec)-$remotesec
ELSE
$diffsec=$localsec-($remotesec+$diffdaysec)
ENDIF
END IF
END IF
IF($result!='OK')
$timediff=3600
END IF
PRINT('local time : '.$localtime)
PRINT('local sec : '.$localsec)
PRINT('remote time : '.$remotetime)
PRINT('remote sec : '.$remotesec)
PRINT('diff sec : '.$diffsec)[/ScriptFTP]
and the result display:
Gilles
A new day and another solution! Now, I'm able to compute the diff time betwen server, but it was not so simple to do. Here the script
[scriptftp="calculate_time_difference_between_servers_v2.ftp"]$result=PUTFILE('timestampspy.txt')
IF($result=='OK')
$result=GETFILE('timestampspy.txt')
IF($result=='OK')
$localtime=GETFILETIME(LOCAL,'timestampspy.txt')
$remotetime=GETFILETIME(REMOTE,'timestampspy.txt')
$localday=((TEXTCUT($localtime,1,4)-1980)*12*30)+(TEXTCUT($localtime,6,2)*12)+(TEXTCUT($localtime,9,2)*30)
$localsec=(TEXTCUT($localtime,12,2)*60*60)+(TEXTCUT($localtime,15,2)*60)+TEXTCUT($localtime,18,2)
$remoteday=((TEXTCUT($remotetime,1,4)-1980)*12*30)+(TEXTCUT($remotetime,6,2)*12)+(TEXTCUT($remotetime,9,2)*30)
$remotesec=(TEXTCUT($remotetime,12,2)*60*60)+(TEXTCUT($remotetime,15,2)*60)+TEXTCUT($remotetime,18,2)
$diffdaysec=(($localday-$remoteday)*24*60*60)
IF($localsec>$remotesec)
$diffsec=($localsec+$diffdaysec)-$remotesec
ELSE
$diffsec=$localsec-($remotesec+$diffdaysec)
ENDIF
END IF
END IF
IF($result!='OK')
$timediff=3600
END IF
PRINT('local time : '.$localtime)
PRINT('local sec : '.$localsec)
PRINT('remote time : '.$remotetime)
PRINT('remote sec : '.$remotesec)
PRINT('diff sec : '.$diffsec)[/ScriptFTP]
and the result display:
PUTFILE("timestampspy.txt")Finaly I can workaround this problem, but it could be really more simple to have a command like GETCLOCKDIFF(). The code already exists in scriptftp for the SYNC(...) command, it could be done in just a few minutes!
Uploading................. timestampspy.txt
GETFILE("timestampspy.txt")
Downloading................. timestampspy.txt
GETFILETIME(LOCAL,"timestampspy.txt")
GETFILETIME(REMOTE,"timestampspy.txt")
local time : 2011_03_22-01_23_15
local sec : 4995
remote time : 2011_03_22-00_23_27
remote sec : 1407
diff sec : 3588
Gilles
Hello Gilles,
Thank you very much for sharing with us your efforts. Certainly you managed to workaround the limitations that ScriptFTP has operating with dates. I hope to get this solved in future versions!
Thank you very much for sharing with us your efforts. Certainly you managed to workaround the limitations that ScriptFTP has operating with dates. I hope to get this solved in future versions!
liked Script FTP? Try our other product Email Parser