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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

Ping then post

Hello,
I am totaly new to perl so please bear with me. What I am looking for is a way for my linux box to test/ping my connection at a set interval, and if it doesnt recieve a response to send a POST to my router that will tell it to reboot.

The code for the web page that launches the reboot is;
<FORM METHOD=POST ACTION="/reboot.html/set">
          <INPUT TYPE=submit NAME=reboot VALUE="Reboot">
          &nbsp;&nbsp;Are you sure? <INPUT TYPE=radio NAME=confirm VALUE=Yes >Yes
          <INPUT TYPE=radio NAME=confirm VALUE=No CHECKED>No
</FORM>

Any help will be much appreciated.
0
red_eye
Asked:
red_eye
  • 4
  • 3
1 Solution
 
ahoffmannCommented:
if your box does not respond to ping, how will you tell it to reboot? Has the router a dedicated connection (serial, or whatever) to the box?
0
 
red_eyeAuthor Commented:
The Linux box and DSL router are on the same side of the connection e.g. they are both on my LAN. If the linux box tries to ping something on the internet and it fails then there is a good chance the router needs a reboot.
0
 
ahoffmannCommented:
you still did not answer my question ...

Anyway, here as I would do it:

<FORM METHOD=POST ACTION="/ping.cgi">
 <INPUT TYPE=text   NAME=ip   VALUE="">
 <INPUT TYPE=submit NAME=ping VALUE="Ping">
</FORM>

when ping.cgi is called, it pings the given IP and returns a OK page:

<H2>Ping "ip" successful</H2>

or another form if the ping failed:

<FORM METHOD=POST ACTION="/reboot.cgi">
  <INPUT TYPE=submit NAME=reboot VALUE="Reboot">
  Are you sure?
  <INPUT TYPE=radio NAME=confirm VALUE=Yes >Yes
  <INPUT TYPE=radio NAME=confirm VALUE=No CHECKED>No
</FORM>

when reboot.cgi is called, it reboots what ever you want by issiung the approriate command.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
red_eyeAuthor Commented:
Sorry I'm not making myself clear. The router, an efficient SpeedStream 5660 has a web interface. From the web interface it can be rebooted. It is connected via ethernet to a D-Link etherswitch. The Linux box is also connected to the etherswitch. So when my WAN/Internet connection is down the Router and Linux box are still connected on my LAN via ethernet. I want a script written in perl to run on the linux box, it should ping the internet and if there is no response to the pin then it should execute the Post method using the following data;

<FORM METHOD=POST ACTION="/reboot.html/set">
         <INPUT TYPE=submit NAME=reboot VALUE="Reboot">
         Are you sure? <INPUT TYPE=radio NAME=confirm VALUE=Yes >Yes
         </FORM>

In other words I want my Linux box when it doesnt find the connection to be up to push the peboot button on my router. A sample of the page I see in my router that I can reboot it from is at;
http://www.pcsites.com/sample/reboot.html

When I access my router via its intergrated web interface if I choose yes on that screen and click on the reboot button the router does a warm reboot.
0
 
ahoffmannCommented:
# push the reboot button:
wget 'http://your-router/reboot.html/set?confirm=Yes&reboot=Reboot'

If you wan to check the response of the router, see man wget, probably the -O option
0
 
red_eyeAuthor Commented:
That worked perfectly now all I need to do is script the rest. Thanks.
0
 
ahoffmannCommented:
good luck.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now