473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Ping A Page, Reddirect if Not Available

Originally posted with Comp.lang.php spelt stupidly incorrectly. Please
accept my apologies for the resultant multi-post....

Hi, I'm cross posting to comp.infosystems.www.authoring.html and
comp.languages.php. Our IT staff who usually do this sort of thing are
rather busy and I am desperately looking at an impending deadline.

My organization's web page is on a server which has php. A work request
web server is on a separate server which I take down frequently for
maintenance, upgrades and tweaking. What I'm trying to do is create a
page, which will be the link to the work request service, that will
first ping the work request server. If the work request service is
active, it will go to it. If it is down, it will redirect to another page.

Is there anywhere on the web which might have sample code for this sort
of thing? All of the suggestions I have be other knowledgeable
colleagues as well as google searches I have done so far either point to
VB scripting/ASP
(http://www.forum4designers.com/archi...-4-209035.html, for
example) or deal with PHP issues that don't seem to address my needs. My
coding knowledge of PHP is non-existent and my html skills are
rudimentary and I don't know anything about how to ping a server. As I
mentioned at the beginning, I'm kind of on my own due to a deadline.

Thanks very much in advance for any leads on this.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Jul 17 '05 #1
4 1914
>My organization's web page is on a server which has php. A work request
web server is on a separate server which I take down frequently for
maintenance, upgrades and tweaking. What I'm trying to do is create a
page, which will be the link to the work request service, that will
first ping the work request server. If the work request service is
active, it will go to it. If it is down, it will redirect to another page.
"ping", assuming you mean that literally (ICMP packets), will not
tell you if the web server is up and able to serve pages. For
example, a web server may ping nicely while it is spending 15 minutes
running fsck cleaning its filesystems after a crashed caused by CPU
overheating due to fan failure, and the web server is not running
during this time.

Is there anywhere on the web which might have sample code for this sort
of thing? All of the suggestions I have be other knowledgeable
colleagues as well as google searches I have done so far either point to
VB scripting/ASP
(http://www.forum4designers.com/archi...-4-209035.html, for
example) or deal with PHP issues that don't seem to address my needs. My
coding knowledge of PHP is non-existent and my html skills are
rudimentary and I don't know anything about how to ping a server. As I
mentioned at the beginning, I'm kind of on my own due to a deadline.


It appears what you may want is requesting a page from the remote
server with a timeout, so if it's down, you find out about it (sorta
quickly). Consider looking at the example code on the stream_set_timeout()
function page on www.php.net, which uses fsockopen() and
stream_set_timeout().

Gordon L. Burditt
Jul 17 '05 #2

"Tim Marshall" <TI****@PurplePandaChasers.Moertherium> wrote in message
news:d3**********@coranto.ucs.mun.ca...
Originally posted with Comp.lang.php spelt stupidly incorrectly. Please
accept my apologies for the resultant multi-post....

Hi, I'm cross posting to comp.infosystems.www.authoring.html and
comp.languages.php. Our IT staff who usually do this sort of thing are
rather busy and I am desperately looking at an impending deadline.

My organization's web page is on a server which has php. A work request
web server is on a separate server which I take down frequently for
maintenance, upgrades and tweaking. What I'm trying to do is create a
page, which will be the link to the work request service, that will
first ping the work request server. If the work request service is
active, it will go to it. If it is down, it will redirect to another page.
Is there anywhere on the web which might have sample code for this sort
of thing? All of the suggestions I have be other knowledgeable
colleagues as well as google searches I have done so far either point to
VB scripting/ASP
(http://www.forum4designers.com/archi...-4-209035.html, for
example) or deal with PHP issues that don't seem to address my needs. My
coding knowledge of PHP is non-existent and my html skills are
rudimentary and I don't know anything about how to ping a server. As I
mentioned at the beginning, I'm kind of on my own due to a deadline.

Thanks very much in advance for any leads on this.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me


In PHP this is super-easy, because HTTP retrieval is an intergral part of
the file-handling mechanism. Something like this will do the job:

<?php

if(fopen("http://www.workrequest.com/", "rb")) {
header("Location: http://www.workrequest.com/");
}
else {
header("Location: /sitedown.php");
}

?>

Jul 17 '05 #3
> Is there anywhere on the web which might have sample code for this sort
of thing? All of the suggestions I have be other knowledgeable


Sample code will be found using PHP's fsockopen function:
http://us4.php.net/fsockopen

Although this is not tested, you could do something like:

<?php
$fp = @fopen("http://www.yahoo.com/NotFound", "r");
if (!$fp) {
// Go Here Instead
header("Location: http://www.example.com/");
exit;
} else {
fclose($fp);
header("Location: http://www.yahoo.com/NotFound");
exit;
}
?>
The above would be it's own php page such as PageFinder.php.
You would link to this php page, and allow it to figure out where to direct
the visitor.
--
-Wil Moore III, MCP
www.digitallysmooth.com
Jul 17 '05 #4
Gordon Burditt wrote:
It appears what you may want is requesting a page from the remote


Will, Chung and Gordan, thanks very much for your prompt replies. I'm
still trying to sort these suggestions, sites and code out, but will
figure this out.

I really appreciate the starting points provided.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sean Cody | last post by:
Does anyone know of an ping module that will work with Windows? I'm currently using os.popen("ping -n1 host") but it's terribly slow when using it a few hundred times. After enumerating my...
2
by: Count László de Almásy | last post by:
Greetings, I'm in need of a simple GUI application that "monitors" a range of hosts using ping and reports on their status by changing the panel color for that host (i.e, green for pingable, red...
0
by: Tim Marshall | last post by:
Hi, I'm cross posting to comp.infosystems.www.authoring.html and comp.languages.php. Our IT staff who usually do this sort of thing are rather busy and I am desperately looking at an impending...
17
by: wana | last post by:
I was reading through original source code of ping for some insight and was confused by unusual code. Entire listing available at: http://www.ping127001.com/pingpage/ping.html #include...
9
by: Mantorok | last post by:
Hi all I want to ping an ipaddress/host to check for a response. Is there any easy way in C#/.Net to do this? Thanks Kev
21
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases...
3
by: shaid | last post by:
Hi all, I want to ping or try to check the avability of a local server. Is there any way to do it directly from an ASP page just by pressing a buttun? I just want to do the "ping" command...
5
by: Sonda | last post by:
how to ping ip address from c language ?
6
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.