Page 1 of 1
?ping ip and graphic shows one or the other on results?
Posted: Mon Nov 10, 2003 3:48 pm
by Minni
I have a friend who asked this question below and I am unable to answer so I am searching for someone who can. Can anyone answer this question?
I am looking for the code that allows you to ping an ip and port and when the ip and port are active then it shows a graphic and when it is not it shows a different graphic. I have tried a few things and have managed to make a pinger but i dont know how to integrate the graphic stuff
here is the pinger i made
Code: Select all
$command = "ping -c1 123.456.789:123456";
system($command);
Thank you

Posted: Mon Nov 10, 2003 3:59 pm
by qads
Code: Select all
<?php
$command = "ping -c1 123.456.789:123456";
$img = "path/to/image";
if(system($command))
{
$img = "path/to/differnet/image";
}
echo "<img src="$img">";
?>
i never have worked with system but try this.
Posted: Mon Nov 10, 2003 4:03 pm
by Minni
Thanks a bunches sweety, I'll see if this helps my friend
Smooches,
Minni
Posted: Tue Nov 11, 2003 5:59 am
by qads
you better be a girl LOL cos i dont want no smooches from a man!

Posted: Tue Nov 11, 2003 8:26 am
by Minni
ROFLMAO
No worries - I'm female (28) the last time I checked
I like to sign my posts like that
Smooches,
Minni
Posted: Tue Nov 11, 2003 8:44 am
by Etherguy
Minni,
If you want to display a graphic only if a host is alive you will need to check the return code from the system command. Otherwise you will display the graphic whether the host is up or not.
Try this.
Code: Select all
<?php
// ping host and port, direct to null to hide all the system ping garbage
$ping = "ping -c 1 123.456.789:123456 >/dev/null";
system($ping,$ret);
// a return of 0 means the host was alive, anything else and the packet did not make it back
if ($ret == 0) {
echo ""<img src="Alive image">";
flush();
}
else {
echo ""<img src="Down image">";
flush();
}
?>
Hope that helps a little.
Posted: Wed Nov 12, 2003 2:15 am
by devork
we can also check from the output returned by system functions being called