WGET 401 Unauthorized

user1192537 picture user1192537 · Feb 8, 2012 · Viewed 76.4k times · Source

I'm trying to use a batch file with WGET to download the public FCC file from here

http://wireless.fcc.gov/uls/data/complete/l_micro.zip

When I intially run the batch file with parameters

wget --server-response -owget.log http://wireless.fcc.gov/uls/data/complete/l_micro.zip 

It fails with an HTTP 401 unauthorized error. I can retry at this point and it keeps failing. However I noticed if I open up IE, start a download and cancel when prompted to save, I can rerun the batch file and it executes perfectly!

Here is my detailed server response from the log

--2012-02-06 14:32:24--  http://wireless.fcc.gov/uls/data/complete/l_micro.zip
Resolving wireless.fcc.gov (wireless.fcc.gov)... 192.104.54.158
Connecting to wireless.fcc.gov (wireless.fcc.gov)|192.104.54.158|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Location: REMOVED - appears to have my IP
  Cache-Control: no-cache
  Pragma: no-cache
  Content-Type: text/html; charset=utf-8
  Connection: close
  Content-Length: 513
Location: REMOVED [following]
--2012-02-06 14:32:24--  REMOVED
Resolving REMOVED... 192.168.2.11
Connecting to REMOVED|192.168.2.11|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 401 Unauthorized
  Cache-Control: no-cache
  Pragma: no-cache
  WWW-Authenticate: NTLM
  WWW-Authenticate: BASIC realm="AD_BCAAA"
  Content-Type: text/html; charset=utf-8
  Proxy-Connection: close
  Set-Cookie: BCSI-CS-8ECFB6B4AA642EF0=2; Path=/
  Connection: close
  Content-Length: 575
Authorization failed.

Here is the log after doing my little IE procedure and getting it to work

--2012-02-08 15:52:43--  http://wireless.fcc.gov/uls/data/complete/l_micro.zip
Resolving wireless.fcc.gov (wireless.fcc.gov)... 192.104.54.158
Connecting to wireless.fcc.gov (wireless.fcc.gov)|192.104.54.158|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Server: Sun-Java-System-Web-Server/7.0
  Date: Fri, 27 Jan 2012 18:37:51 GMT
  Content-type: application/zip
  Last-modified: Sun, 22 Jan 2012 11:18:09 GMT
  Etag: "46fa95c-4f1bf071"
  Accept-ranges: bytes
  Content-length: 74426716
  Connection: Keep-Alive
  Age: 1045014
Length: 74426716 (71M) [application/zip]
Saving to: `l_micro.zip'

Any help is appreciated!

Answer

Federico Giorgi picture Federico Giorgi · Mar 20, 2013

If the website has simply a htpassword setup, you can try:

wget --user=admin --ask-password https://www.yourwebsite.com/file.zip