Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
    # Retrieve Netgear DG834G WAN IP address.
    wget --http-user='<my_account>' --http-password='<my_password>' -O 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>'
    wget  -qO /dev/null --user='<my_account>' --password='<dummy_pwd>'

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

user@debian:/tmp# ./
--2011-09-26 14:23:10--
Connecting to connected.
HTTP request sent, awaiting response... 401 Unauthorized
**Unknown authentication scheme**.
**Authorization failed**.
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# ./
--2011-09-26 14:28:46--
Connecting to connected.
HTTP request sent, awaiting response... 401 Unauthorized
Connecting to 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]
=== ===

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

You must log in to answer this question.

Browse other questions tagged .