fusion400 Posted September 12, 2010 Share Posted September 12, 2010 Hello i have this code below that connects to an ftp server this works really well but i want to make it bullet proof so it tries to reconnect and upload the files until it recieves that the transfer was successfull how can this be done in an easy way? The script should never stop trying to reconnect until it is completely successfull. So even if the ftp server is temporarily down, overloaded by too many connections or that the internet connection is not work it should still keep trying. $FTP = _FTP_Open('NC FTP') $hConnect = _FTP_Connect($FTP, $SERVER, $NAME, $PASS,1) $Ftpd = _FTP_DirCreate($hConnect, $date) $ftps = _FTP_DirSetCurrent($hConnect, $date) $Ftpp = _FTP_FilePut($hConnect,$datornamn & "-1.jpg", $datornamn & "-1.jpg") $Ftpp = _FTP_FilePut($hConnect,$datornamn & "-2.jpg", $datornamn & "-2.jpg") $Ftpc = _FTP_Close($FTP) Link to comment Share on other sites More sharing options...
Zibit Posted September 12, 2010 Share Posted September 12, 2010 just a long shot here but maybe: $FTP = _FTP_Open('NC FTP') while 1 sleep(100) $hConnect = _FTP_Connect($FTP, $SERVER, $NAME, $PASS,1) if $hConnect <> @error then exitloop wend $Ftpd = _FTP_DirCreate($hConnect, $date) $ftps = _FTP_DirSetCurrent($hConnect, $date) $Ftpp = _FTP_FilePut($hConnect,$datornamn & "-1.jpg", $datornamn & "-1.jpg") $Ftpp = _FTP_FilePut($hConnect,$datornamn & "-2.jpg", $datornamn & "-2.jpg") $Ftpc = _FTP_Close($FTP) Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
Tvern Posted September 12, 2010 Share Posted September 12, 2010 I'd do something line this: Could do with some user feedback though. I'm not sure how to test the status of the current _FTP_Connect and you might need to make sure it's disconnected before attempting to reconnect. Perhaps someone else has an idea for that. #include <FTPEx.au3> Local $hFTP, $hConnect Local $bFTPd, $bFTPp Local $sServer = "" Local $sName = "" Local $sPass = "" Local $sDate = "" Local $sDatornNamn = "" $hFTP = _FTP_Open('NC FTP') While 1 Sleep(500) $hConnect = _FTP_Connect($hFTP, $sServer, $sName, $sPass,1) If @error Then ContinueLoop If Not $bFTPd Then $bFTPd = _FTP_DirCreate($hConnect, $sDate) If Not $bFTPd Then ContinueLoop If Not $bFTPp Then $bFTPp = _FTP_FilePut($hConnect,$sDatornNamn & "-1.jpg", $sDatornNamn & "-1.jpg") If Not $bFTPp Then ContinueLoop _FTP_FilePut($hConnect,$sDatornNamn & "-2.jpg", $sDatornNamn & "-2.jpg") If @error Then ContinueLoop Else ExitLoop EndIf WEnd _FTP_Close($hFTP) Link to comment Share on other sites More sharing options...
fusion400 Posted September 13, 2010 Author Share Posted September 13, 2010 I'd do something line this: Could do with some user feedback though. I'm not sure how to test the status of the current _FTP_Connect and you might need to make sure it's disconnected before attempting to reconnect. Perhaps someone else has an idea for that. #include <FTPEx.au3> Local $hFTP, $hConnect Local $bFTPd, $bFTPp Local $sServer = "" Local $sName = "" Local $sPass = "" Local $sDate = "" Local $sDatornNamn = "" $hFTP = _FTP_Open('NC FTP') While 1 Sleep(500) $hConnect = _FTP_Connect($hFTP, $sServer, $sName, $sPass,1) If @error Then ContinueLoop If Not $bFTPd Then $bFTPd = _FTP_DirCreate($hConnect, $sDate) If Not $bFTPd Then ContinueLoop If Not $bFTPp Then $bFTPp = _FTP_FilePut($hConnect,$sDatornNamn & "-1.jpg", $sDatornNamn & "-1.jpg") If Not $bFTPp Then ContinueLoop _FTP_FilePut($hConnect,$sDatornNamn & "-2.jpg", $sDatornNamn & "-2.jpg") If @error Then ContinueLoop Else ExitLoop EndIf WEnd _FTP_Close($hFTP) Thanks alot for all the help 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