cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: How to auto-retry a servered connection?

From: <PsiStormYamato_at_cs.com>
Date: Mon, 21 Jul 2008 07:04:15 EDT

Looping the command until (%errorlevel% = 0) only worked for the first
instance of the connection loss, since failure to establish a connection returns an
exit code of "0". So, I added an additional check to see if the trace log size
was exactly 98 bytes, which the exact size it becomes if it reports a failure
to reach the host. (An exact string comparision of the trace would have
optimal, but I'm using a batch file, and DOS throws a fit over special charachters.
lol)

Looping the command through these two checks solves my original problem.
Although, a built-in function would be convenient.

Here's the batch file, in case anyone wants to see it. I'm using it with
Windows XP, btw.

/* cURL Starter.bat */
setlocal

set cURL="C:\Program Files\curl-7.18.2-win32-nossl-sspi\curl"
set MapsILackURLs=MapsILackURLs.txt
set cURL_Trace=cURL_Trace.txt

for /f "tokens=*" %%G in (%MapsILackURLs%) do (
    set TargetURL=%%G
    call :RuncURL "%%G"
    call :CheckForErrors "%%G"
)
endlocal & goto :eof

:RuncURL
%cURL% -C - -L -O --retry 999 -S --trace "%cURL_Trace%" %TargetURL%
goto :eof

:CheckForErrors
ping 127.0.0.1
if %errorlevel% GTR 0 (
    call :RuncURL
    call :CheckForErrors
)
call :TraceCheck %cURL_Trace%
goto :eof

:TraceCheck
set TraceFileSize=%~z1
del %cURL_Trace%
ping 127.0.0.1
if "%TraceFileSize%" EQU "98" (
    call :RuncURL
    call :TraceCheck %cURL_Trace%
)
goto :eof

/* End of File */

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-07-21