Solved

Ping then post

Posted on 2002-07-17
7
193 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
  • 4
  • 3
7 Comments
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:red_eye
Comment Utility
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 100 total points
Comment Utility
# 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
Comment Utility
That worked perfectly now all I need to do is script the rest. Thanks.
0
 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
good luck.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now