The Gang of Five
The forum will have some maintenance done in the next couple of months. We have also made a decision concerning AI art in the art section.


Please see this post for more details.

Scripting Help

landbeforetimelover

  • Member+
  • Littlefoot
  • *
    • Posts: 8495
  • Littlefoot
    • View Profile
    • http://www.thelandbeforetime.org
Hello.  I just wanted to see if anyone knew a good way to write a small script using server side scripting that would allow me to put the status of my server onto a simple page made of only HTML without having to have another separate server.  Ya know, something remarkably simple.  I would like to have a script that would show one image if my server is up and another different image if my server is down.  It would sort of look like this:

#T{var - if '192.168.2.3'=true then img='serverup.jpg'}
#F{var - if '192.167.2.3'=true then img='serverdown.jpg'}

The problem is it would have to be quite a complex script because it would have to try to access my server once every 5 seconds or so in order to keep up an accurate status.  I don't know if you could use some sort of PHP or what but I'm at a loss.  I haven't been able to find much of anything on a script like this through google.  Does such a script even exist?  If not, can it be created from scratch using PHP or Javascript?


Lillefot

  • Cera
  • *
    • Posts: 3245
    • View Profile
First off:
I have very little experience with PHP.
But, if I've get this right, you'd want a certain picture to show when the server's up... and another one when it's down?
I've seen Javascripts that change pictures over certain commands. (simple, I know)

One of them, the simple weekdays one:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
today = new Date();
day = today.getDay();
arday = new Array("sunday.jpg", "monday.jpg", "tuesday.jpg",
"wednesday.jpg", "thursday.jpg", "friday.jpg", "saturday.jpg");

document.write("<img src='" + arday[day] + "'>");
// End -->
</script>


Call me noob, as I'm only speculating with my own ideas, but:
Couldn't there be a way to edit such a Javascript for that purpose?
Instead of weekdays, in this case?
Is it possible to mix java with PHP?
This is where my experience so humby ends.  -_-

Just doing my part.
IF you find a solution, please share it, would you? (I'm sure it's out there somewhere)

Best of luck!
Do well. Live well. And dress very well.


landbeforetimelover

  • Member+
  • Littlefoot
  • *
    • Posts: 8495
  • Littlefoot
    • View Profile
    • http://www.thelandbeforetime.org
Well I've never used Javascript to directly communicate with another website in this manner.  I mean, how would it KNOW if the website responded correctly?  Sure you can write a script that tells it to visit that site every couple of seconds, but I don't have any idea how it would tell if the site responded or not.  My server itself would have to send some sort of file that confirmed that it was responding and at the same time I would have to teach javascript how to read that file and interpret its meanings.  I would have to write a script that asked my server for a file.  If my server gave it that file, it would respond by putting up one picture.  If it didn't receive the file then a different picture would show.  The question is, how to I make the Javascript just read the file?  It's going to want to download it and I can't have it doing that.  Where is it going to download the file to? :bang This is all so confusing!!! :(


Lillefot

  • Cera
  • *
    • Posts: 3245
    • View Profile
Yeah, that's a good point. It makes sense.

This is really more programming language, isn't it?
Well, we'll see if anyone else has something to tell.



Do well. Live well. And dress very well.


Petrie.

  • Hatchling
  • *
    • Posts: 0
  • It's good to be the king!
    • View Profile
No programming experience here.  Sorry.