using curl to log in to router

This is a discussion on using curl to log in to router within the Linux Administration forums, part of the Linux Forums category; I'm trying to use curl to log in to a router so I can retrieve the current WAN IP ...


Go Back   Usenet Forums > Linux Forums > Linux Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-01-2006
Gary Dale
 
Posts: n/a
Default using curl to log in to router

I'm trying to use curl to log in to a router so I can retrieve the
current WAN IP address periodically - it changes at least twice a week
and getting it manually is annoying (obviously I need to do this from
the LAN side). I can get the appropriate line through curl and grep once
I'm logged in, but I'm not sure how to do the submit. The examples I've
seen use the name of the submit button to post the form data, but the
button on my router doesn't have a name. The relevant HTML code is

<BODY bgcolor="#0000FF">
<form action="login.htm" method="post" name="tF">
<input type="hidden" name="page" value="login">
<table border="0" width="100%" height="184" cellspacing="0">
<tr>
<td width="50%" height="19" align="right">
<font face="Arial, Helvetica, sans-serif" size="2"
color="#FFFFFF">Password&nbsp;&nbsp;&nbsp;:</font></td>
<td width="50%" height="19" align="left">
<INPUT type="password" maxLength=12 size=9 name=pws></td><p>
</tr>
<tr>
<td width="50%" height="19" align="right">
<INPUT type="submit" value="Login"><img src="image/PIXEL.GIF"
width="6" height="1">
</td>
<td width="50%" height="19" align="left">
<INPUT class=button onclick=window.close(); type=button value=Cancel>
</td>
</tr>
</table>
</body>
</FORM>
</BODY>


I'm not sure if the mistake in the HTML coding (incorrect closure of the
</body> and </form> tags is important, but the login form does work if I
log in through a browser. I just need to do it through curl!

So if anyone can tell me how to use curl to do a submit without a named
submit button, I'd appreciate it. :)
Reply With Quote
  #2 (permalink)  
Old 02-05-2006
alex
 
Posts: n/a
Default Re: using curl to log in to router

Gary Dale wrote:
> I'm trying to use curl to log in to a router so I can retrieve the
> current WAN IP address periodically - it changes at least twice a week
> and getting it manually is annoying (obviously I need to do this from
> the LAN side). I can get the appropriate line through curl and grep once


Maybe I'm just lazy, but rather than curl i just use the following line:


wget http://checkip.dyndns.org -qO - | cut -d : -f 2 | cut -d '<' -f 1


should work just fine for you.. as long as you have wget & cut.. ;)


--
alex

USER, n.:
The word computer professionals use when they mean "idiot".
Reply With Quote
  #3 (permalink)  
Old 02-05-2006
Gary Dale
 
Posts: n/a
Default Re: using curl to log in to router

alex wrote:
> Gary Dale wrote:
>
>> I'm trying to use curl to log in to a router so I can retrieve the
>> current WAN IP address periodically - it changes at least twice a week
>> and getting it manually is annoying (obviously I need to do this from
>> the LAN side). I can get the appropriate line through curl and grep once

>
>
> Maybe I'm just lazy, but rather than curl i just use the following line:
>
>
> wget http://checkip.dyndns.org -qO - | cut -d : -f 2 | cut -d '<' -f 1
>
>
> should work just fine for you.. as long as you have wget & cut.. ;)
>
>


Yes. In fact curl and grep can do the same thing (probably a bit simpler
too) - as long as the service exists and is free. On the other hand,
querying the router will always be there and be free. I just need to
ensure that the script containing the password is properly secured.

I've got this working on another router from a different manufacturer,
but not this particular one. The other router uses a normal
user-id:password syntax to log in. Then it's just a matter of
identifying the correct page to extract the ip address from.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:12 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0