Link to home
Start Free TrialLog in
Avatar of vincevincevince
vincevincevince

asked on

How to check if a domain is live even if PING is blocked?

I have been using PING to check if a domain is live, however, some domains, depsite being available on port 80, are blocking PING.

       $response=shell_exec("ping $site -n -c 1 -w 2 -W 2");

I want a fast way of testing port 80, if it is live or not.  This must be an automated solution as it needs to be part of a script.
Avatar of philipp999
philipp999

Hi,

would this work? (needs netcat installed):
printf "GET / HTTP/1.0\n\n" | nc -w $timout $host $port | perl -pe 'if(m|^HTTP/1\.1 200 OK|) { print "OK\n"; } else { print "NOPE\n";} exit(1);'

best,

philipp
ASKER CERTIFIED SOLUTION
Avatar of blkline
blkline

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 vincevincevince

ASKER

Barry, that is just perfect, thanks :-)

You really deserve the points, I wish I had more to give