Showing posts with label PING. Show all posts
Showing posts with label PING. Show all posts

7.08.2010

How PING.BAT works




Comments:


  • See previous post
  • Command line options on the PING

    • -n Count, Determines the number of echo requests to send. The default is 4 requests. In the BAT file this is set to 2
    • -w Timeout, Enables you to adjust the time-out (in milliseconds). The default is 1,000 (a 1-second time-out). In the BAT file this is set to 750

  • Click on images above for larger view
  • If the PING is successful, "TTL=" is found in the return string ... else
  • If the PING fails, "TTL=" is not found
  • If PING is successful, the device name plus "was PINGABLE" is written to the comma delimited file
  • Else, the device name plus "was NOT pingable" is written to the file
  • See below for the PING log file




7.07.2010

Neat PING BAT file


Comment: I'm troubleshooting why we were unable to remotely upgrade several hundred computers. I had been manually pinging each one ... like this

PING WFC1A000AE0C975

I decided to write a BAT file to do the work. Well someone had done this for me.

here

With this as the basis:

The BAT FILE:

@echo off

(Set InputFile=C:\temporary\list.txt)

title,Pinging list of computers &color 9e

::datestamp
for /f "tokens=2-4 skip=1 delims=(-./)" %%i in ('echo.^|date') do (
for /f "tokens=1-4 delims=-./ " %%m in ('date /t') do (
(set dow=%%m)&(set %%i=%%n)&(set %%j=%%o)&(set yy=%%p) ) )
For /F "tokens=1,2 delims=:, " %%i in ('TIME /T') Do (Set HHMM=%%i%%j)

(Set OutputFile=c:\temporary\Pinglog %yy%-%mm%-%dd% %HHMM%.txt)

If Exist "%OutputFile%" Del "%OutputFile%"


For /F "usebackq eol=;" %%* In ("%InputFile%") Do (
Ping.exe -n 2 -w 750 %%* | Find/i "TTL=" >Nul && (
echo.%%* "was PINGABLE">>"%OutputFile%")|| (
echo.%%* "was NOT pingable">>"%OutputFile%")
echo.done %%*,)


The input file (computer names changed!):

WFC1A000AE0C975
WFCPTXWLRESBOX5
WFCPTXWLH39MXC1
WFCPTXWLDN6MXC1
WFC2300D74C069C
WFCPTXWLF43MXC1
WFCPTXWL7RFMXC1
WFCPTXWL5L8MXC1
WFCPTXWLTRAIN19
WFCPTXWL979MXC1
WFCPTXWLRESBOX4
WFCPTXWL363MXC1
WFC120097EAA8AB
WFCPTXWL3P8MXC1
WFCPTXWL8JP9YF1


The output file:

WFC1A000AE0C975 "was NOT pingable"
WFCPTXWLRESBOX5 "was NOT pingable"
WFCPTXWLH39MXC1 "was NOT pingable"
WFCPTXWLDN6MXC1 "was NOT pingable"
WFC2300D74C069C "was PINGABLE"
WFCPTXWLF43MXC1 "was NOT pingable"
WFCPTXWL7RFMXC1 "was NOT pingable"
WFCPTXWL5L8MXC1 "was NOT pingable"
WFCPTXWLTRAIN19 "was NOT pingable"
WFCPTXWL979MXC1 "was NOT pingable"
WFCPTXWLRESBOX4 "was NOT pingable"
WFCPTXWL363MXC1 "was NOT pingable"
WFC120097EAA8AB "was NOT pingable"
WFCPTXWL3P8MXC1 "was NOT pingable"
WFCPTXWL8JP9YF1 "was NOT pingable"