Looping Ping

210 pts.
Tags:
Batch debugging
Batch jobs
LOOP statement
Ping
Could someone please help me with this command to loop through the IPlist table and report results. It doesn't seem to be looping properly at this time. Thank you.

:: "Set Variables" for /f "tokens=*" %%I in (IPlist.txt) do @Set $IP=%%I @Set OutputFile=PingResults.log

:: "Set Time stamp" @FOR /F "tokens=*" %%* IN ('date/t') Do @(set $dt=%%*) @FOR /F "tokens=*" %%* IN ('time/t') Do @(set $tm=%%*)

:: "Ping Computer" @start/b/w PING %1 -a %$IP% -n 2 -w 100>"temp.txt" @FOR /F "tokens=2,3 delims= " %%A IN (%tmpFile%) DO @IF "%%B"=="[%$IP%]" SET $PC=%%A ||@rem

:: "Get Status" @Set $Status=Off-Line @IF EXIST "temp.txt" @GoTo READSTATUS @Set $Status=Ping-Error @GoTo RESULTS

:READSTATUS @Set errorlevel= @Type "temp.txt" | Find "TTL=" >nul @IF Not errorlevel = 1 @Set $Status=On-Line

:RESULTS @echo results: %$dt% %$tm% %$PC%[%$IP%] ^= %$Status% >>"%OutputFile%"

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • ConFlicker
    The syntax shown above was formated incorrectly - it should like like: :: "Set Variables" for /f "tokens=*" %%I in (IPlist.txt) do @Set $IP=%%I @Set OutputFile=PingResults.log :: "Set Time stamp" @FOR /F "tokens=*" %%* IN ('date/t') Do @(set $dt=%%*) @FOR /F "tokens=*" %%* IN ('time/t') Do @(set $tm=%%*) :: "Ping Computer" @start/b/w PING %1 -a %$IP% -n 2 -w 100>"temp.txt" @FOR /F "tokens=2,3 delims= " %%A IN (%tmpFile%) DO @IF "%%B"=="[%$IP%]" SET $PC=%%A ||@rem :: "Get Status" @Set $Status=Off-Line @IF EXIST "temp.txt" @GoTo READSTATUS @Set $Status=Ping-Error @GoTo RESULTS :READSTATUS @Set errorlevel= @Type "temp.txt" | Find "TTL=" >nul @IF Not errorlevel = 1 @Set $Status=On-Line :RESULTS @echo results: %$dt% %$tm% %$PC%[%$IP%] ^= %$Status% >>"%OutputFile%"
    210 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following