Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

New to Linux, I'm trying to query the status page of my DG834G modem with wget from my Dockstar running debian. Not sure it makes any difference but I'm connected to the Dockstar thru SSH from a Windows box. The idea is to retrieve the WAN IP (please, no DynDNS answer) from one of the modem admin pages and I have made a bash script that looks like :

    user@debian:/tmp# vi dg834g.sh
    #!/bin/sh
    # Retrieve Netgear DG834G WAN IP address.
    wget --http-user='<my_account>' --http-password='<my_password>' -O s_status.htm http://192.168.0.1/s_status.htm
    myIP=$(sed -En '/IP Address/{n;s/<[^>]*>|[[:space:]]*//gp;q;}' < s_status.htm)
    echo "=== $myIP ==="
    rm s_status.htm
    wget  -qO /dev/null --user='<my_account>' --password='<my_password>' http://192.168.0.1/logout.htm
    wget  -qO /dev/null --user='<my_account>' --password='<dummy_pwd>' http://192.168.0.1/logout.htm

If I just run the bash script, no matter how many times, I get the following :

user@debian:/tmp# ./dg834g.sh
--2011-09-26 14:23:10--  http://192.168.0.1/s_status.htm
Connecting to 192.168.0.1:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
**Unknown authentication scheme**.
**Authorization failed**.
0
rm: cannot remove `s_status.htm': No such file or directory

However if, just once, I connect to admin pages of the modem from the Windows box, fully logout from the admin pages and then run the bash script, I get :

user@debian:/tmp# ./dg834g.sh
--2011-09-26 14:28:46--  http://192.168.0.1/s_status.htm
Connecting to 192.168.0.1:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Connecting to 192.168.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/HTML]
Saving to: `s_status.htm'
   [ <=>                                   ] 5,033       --.-K/s   in 0.02s
2011-09-26 15:28:47 (222 KB/s) - `s_status.htm' saved [5033]
=== 63.169.61.57 ===
user@debian:/tmp#

I'm not sure why I first get a "401 Unauthorized" (waiting for user and pwd ?) but at least I'm getting what I was looking for though not in a satisfactory manner!

Since I want to automate the retrieval of the WAN IP every few minutes and FTP it to some site when it changes, I'm not half-way thru the task...

If it may help, the Dockstar runs a web server which is accessible from the web whether the Windows box is switched on or off (normal behaviour).

Anyone can think of a reason why I first need to login and logout with the Windows box to get the bash do what it's supposed to do and how to remedy this weird behaviour ?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.