Galop wrote:
> I need to execute few file transfer commands from a local system
> only after the remote destination is reachable. Example:
>
> Check whether I can reach 192.168.32.x
> Then execute file transfer commands.
>
> I tried ping the remote site and capture the %errorlevel%. But this
> is "0" for success or failure.
Hi
This is a "bug" in Win2k's ping.exe that is fixed in WinXP.
The best solution I have found to detect if a computer is online or not
is to search for the text "TTL=" in the output from ping.exe. I have
found it to work all situations/languages I have come up with.
So this should work fine for both WinXP and Win2k:
'--------------------8<----------------------
set host=128.33.12.144
set connected=N
for /f "Tokens=*" %%c in ('ping -n 1 %host% ^| FIND "TTL="') do (
set connected=Y
)
if "%connected%" EQU "Y" echo %host% is online
'--------------------8<----------------------
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scr...r/default.mspx