acrane76 Posted March 5, 2018 Share Posted March 5, 2018 (edited) Hello how i can upload a file to a ftp server every 5 minutes the same file , and every 5 minutes the file in the server ftp must create always a new file with a random name , for example FileName-ufcxe.7z FileName-tcxaw.7z FileName-atdtx.7z #include <FTPEx.au3> ;Online Backup $source = '"Test*"' ;Source directory to backup $7Zfile = "BackupsDirectoryFileName.7z" ;Backup file name $pw = "-p12345 -mhe" ;7-Zip Password (7z file will be password protected with 12345) FileDelete($7Zfile) sleep(500) ;Change "C:Apps" to where 7-Zip is installed Run("7zG a " & $7Zfile & " " & $pw & " " & $source) ;Upload Backup to Server ProcessWaitClose("7zG.exe") $server = 'ftp.test.com' ;FTP Server $username = 'test' ;FTP Username $pass = 'test' ;FTP Password $Open = _FTP_Open('MyFTP Control') $Conn = _FTPConnect($Open, $server, $username, $pass,0,1,0x08000000) ;Hard drive source file and server directory (change to suit) $Ftpp = _FtpPutFile($Conn,"BackupsDirectoryFileName.7z", '/FileName.7z' , 0x08000000) Func _FTPConnect($l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_ServerPort = 0, $l_Service = 1, $l_Flags = 0, $l_Context = 0) Local $ai_InternetConnect = DllCall('wininet.dll', 'long', 'InternetConnect', 'long', $l_InternetSession, 'str', $s_ServerName, 'int', $i_ServerPort, 'str', $s_Username, 'str', $s_Password, 'long', $l_Service, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_InternetConnect[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_InternetConnect[0] EndFunc Func _FtpPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0) Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context) If @error OR $ai_FTPPutFile[0] = 0 Then SetError(-1) Return 0 EndIf Return $ai_FTPPutFile[0] EndFunc Edited March 6, 2018 by acrane76 Link to comment Share on other sites More sharing options...
Bilgus Posted March 5, 2018 Share Posted March 5, 2018 The random name seems like a waste $Ftpp = _FtpPutFile($Conn, 'C:\program files\text.txt', '/public_html/text' & @MDAY & @MON & @YEAR & "-" & @HOUR & @ MIN & @SEC &'.txt') How about appending date + time? @MSEC Milliseconds value of clock. Range is 000 to 999. The update frequency of this value depends on the timer resolution of the hardware and may not update every millisecond. @SEC Seconds value of clock. Range is 00 to 59 @MIN Minutes value of clock. Range is 00 to 59 @HOUR Hours value of clock in 24-hour format. Range is 00 to 23 @MDAY Current day of month. Range is 01 to 31 @MON Current month. Range is 01 to 12 @YEAR Current four-digit year @WDAY Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday. @YDAY Current day of year. Range is 001 to 366 (or 001 to 365 if not a leap year) Link to comment Share on other sites More sharing options...
acrane76 Posted March 6, 2018 Author Share Posted March 6, 2018 (edited) The random name seems like a waste $Ftpp = _FtpPutFile($Conn, 'C:\program files\text.txt', '/public_html/text' & @MDAY & @MON & @YEAR & "-" & @HOUR & @ MIN & @SEC &'.txt') How about appending date + time? @MSEC Milliseconds value of clock. Range is 000 to 999. The update frequency of this value depends on the timer resolution of the hardware and may not update every millisecond. @SEC Seconds value of clock. Range is 00 to 59 @MIN Minutes value of clock. Range is 00 to 59 @HOUR Hours value of clock in 24-hour format. Range is 00 to 23 @MDAY Current day of month. Range is 01 to 31 @MON Current month. Range is 01 to 12 @YEAR Current four-digit year @WDAY Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday. @YDAY Current day of year. Range is 001 to 366 (or 001 to 365 if not a leap year) this for me does not work , i get a error when i try to compile the autoit script to a exe Edited March 6, 2018 by acrane76 Link to comment Share on other sites More sharing options...
acrane76 Posted March 6, 2018 Author Share Posted March 6, 2018 16 hours ago, Bilgus said: $Ftpp = _FtpPutFile($Conn, 'C:\program files\text.txt', '/public_html/text' & @MDAY & @MON & @YEAR & "-" & @HOUR & @ MIN & @SEC &'.txt') this does not work Link to comment Share on other sites More sharing options...
Bilgus Posted March 6, 2018 Share Posted March 6, 2018 this is valid autoit $FileSuffix = @MDAY & @MON & @YEAR & "-" & @HOUR & @MIN & @SEC ;Hard drive source file and server directory (change to suit) $Ftpp = _FtpPutFile($Conn,"BackupsDirectoryFileName.7z", '/FileName' & $FileSuffix & '.7z' , 0x08000000) What doesn't work? Link to comment Share on other sites More sharing options...
acrane76 Posted March 6, 2018 Author Share Posted March 6, 2018 (edited) 44 minutes ago, Bilgus said: this is valid autoit $FileSuffix = @MDAY & @MON & @YEAR & "-" & @HOUR & @MIN & @SEC ;Hard drive source file and server directory (change to suit) $Ftpp = _FtpPutFile($Conn,"BackupsDirectoryFileName.7z", '/FileName' & $FileSuffix & '.7z' , 0x08000000) What doesn't work? now works thanks Edited March 6, 2018 by acrane76 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now