Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-17
3
Medium Priority
?
371 Views
Last Modified: 2011-04-14
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.
0
Comment
Question by:vincevincevince
3 Comments
 

Expert Comment

by:philipp999
ID: 12089033
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
0
 
LVL 6

Accepted Solution

by:
blkline earned 400 total points
ID: 12090018
Perhaps something like:

wget -q -O /dev/null URL && echo "success"

or

wget -q -O /dev/null URL || echo "failure"

might fit the bill?  

URL can be ftp://  or http:// styles.

wget has quite a number of options from which to choose for timeouts and retries and such.

Barry
0
 
LVL 1

Author Comment

by:vincevincevince
ID: 12091172
Barry, that is just perfect, thanks :-)

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

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question