Link to home
Start Free TrialLog in
Avatar of Simon336697
Simon336697Flag for Australia

asked on

PInging by IP Address

Hi guys hope you are well and can help.

I currently run this script by determining if a host is up by pinging its hostname.
What i would like to do though is modify the below script to instead pinging by hostname, ping by its ip address.
Any help greatly appreciated.
@echo off
setlocal enabledelayedexpansion
for /f %%c in (computers.txt) do (
  call :GETINFO %%c
  echo %%c: !Availability!>>availability.txt
)
goto :eof
 
:GETINFO
if [%1]==[] goto :eof
Set Availability=
ping %1 -n 2 -w 100 >nul 2>&1  
If %errorlevel%==1 goto DOWN
 
echo %1: Up
Set Availability=Up
goto :eof
 
:DOWN
echo %1: Down
Set Availability=Down

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Giovanni
Giovanni
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Simon336697

ASKER

Thanks guys to all 3 of you.

Bill, nslookup is a DNS-specific lookup tool, which is why id prefer to use that instead of ping.

The other thing about using nslookup is that you can query the DNS database without the machine being online.

Thanks to all of you really appreciate all your help.