"K" <> wrote in message
news:...
> Is it possible to script a ping or similar to check if a remote host
> responds and if it doesn't then launch a second script to perform certain
> actions?
>
> Alternatively, can the public IP (the one on the outside of my NAT) be
> checked and if it's one IP do A but if it's another do B?
>
> We have 2 internet feeds with twodifferent suppliers and hardware that
> switches them over. Each has a different set of IP addresses and we need
> to run some commands when it switches over, however we don't know if has
> switched until it fails, an dwhen this happens out of hours it can cause
> problems.
Here you go:
@echo off
ping PCx | find /i "bytes=" && goto :eof
rem Your commands go here
To check your external IP:
@echo off
pushd "%temp%"
if exist n09230945.asp del n09230945.asp
d:\tools\wget
www.whatismyip.com/automation/n09230945.asp -onul
for /F %%a in (n09230945.asp) do set ExternalIP=%%a
if exist n09230945.asp del n09230945.asp
popd
echo Your external IP is %ExternalIP%
This batch file needs d:\Tools\wget.exe which you can download from
http://users.ugent.be/~bpuype/wget/#download.