473,574 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.infosystem s.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 1922
>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_time out()
function page on www.php.net, which uses fsockopen() and
stream_set_time out().

Gordon L. Burditt
Jul 17 '05 #2

"Tim Marshall" <TI****@PurpleP andaChasers.Moe rtherium> 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.infosystem s.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("Locatio n: http://www.workrequest .com/");
}
else {
header("Locatio n: /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("Locatio n: http://www.example.com/");
exit;
} else {
fclose($fp);
header("Locatio n: 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
8399
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 domain of machines I'm trying to ping them to determine if they are active before connecting to them via WMI (which takes forever to timeout). --
2
2976
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 for unreachable). Does anyone know of any existing opensource program that does this? Preferably Python so I can extend it easily. If not,...
0
1236
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 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...
17
18188
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 #include #include #include #include #include #include #include #include #include #include #include
9
15296
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
30500
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 (connected/disconnected), system call returns 0. Can someone please show what I am doing wrong? How to check the actual result of the ping status using C++ on Redhat...
3
4262
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 direcdry from an ASP page! Thanks, Shai
5
7395
by: Sonda | last post by:
how to ping ip address from c language ?
6
3450
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 wondering if anyone has a ping function they could share with me. I have done some searching on this but cannot find anything specifically for vb2003. ...
0
7730
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8058
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8241
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7820
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5624
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5301
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3742
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2249
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1061
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.