?
Solved

Ping then post

Posted on 2002-07-17
7
Medium Priority
?
231 Views
Last Modified: 2010-03-05
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
Comment
Question by:red_eye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7160569
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
 

Author Comment

by:red_eye
ID: 7160627
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7160690
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:red_eye
ID: 7160722
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
 
LVL 51

Accepted Solution

by:
ahoffmann earned 400 total points
ID: 7160761
# 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
 

Author Comment

by:red_eye
ID: 7160776
That worked perfectly now all I need to do is script the rest. Thanks.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7160801
good luck.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question