Advertisements

How to install wget in Mac OS X

wget is a really handy command line utility, but unfortunately not included in OS X. Curl could be a suitable replacement, but frequently scripts are written with wget, and it can be difficult and time-consuming to convert them to using curl.

Users interested in installing wget should first install Homebrew and then run:

brew install wget

This will install wget from Homebrew.

The below steps are deprecated and likely no longer work at all:

Below are the steps required to install a working wget on Mac OS X. This has been tested on OS X 10.6 Lion.

Install XCode from http://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12 (at this time, it’s a 1.5GB download.)

Launch XCode, updating if necessary.

Go to Preferences > Downloads, and install Command Line Tools

Now open a terminal and perform the following steps at the command line one at a time to download, extract, configure, compile, and install wget:

curl -O http://ftp.gnu.org/gnu/wget/wget-1.14.tar.gz
tar xvzf wget-1.14.tar.gz
cd wget-1.14
./configure --with-ssl=openssl
make
sudo make install

You should now have a working wget installed in /usr/local/bin. Confirm by trying

$ wget
wget: missing URL
Usage: wget [OPTION]... [URL]...
Try `wget --help' for more options.

Feel free to comment below. Thanks!

2/7/2016: I got an email from someone who says this no longer works and gives the following message:

configure: error: –with-ssl=openssl was given, but SSL is not available.

If anyone has advice, please contact me. Thanks!

 

Advertisements

, , , ,

  1. #1 by gulli on April 7, 2013 - 8:15 pm

    Mike,

    Thanks for the info.

    I followed your instructions to install wget
    but this is what I get:
    -bash: wget: command not found

    I tried it twice, thinking that the initial try that I had done in the Downloads folder may have been the cause but not.
    Also, the curl command does not relaly download the file from the GNU ftp site.
    It downloads a file that cannot be unzipped (only 308 bytes in size).
    I used the browser to get the correct file…

    Thanks again.

    Gulli

    • #2 by Mike on April 18, 2013 - 8:19 pm

      Might be an issue with curl, but I don’t think so. It worked when I tried it.

      Anyone else having this issue?

    • #3 by RCid on July 14, 2013 - 10:03 am

      It could be that you successfully installed it but any path is pointing to it. Which means you’ll not be able to call it from the anywhere in the command line.

      1) Try to locate where it is. Use this command or similar:

      find /usr -name wget

      In my case it returned

      /usr/local/bin/wget

      You could literally go to that location and run wget from there every time you need to…. or

      2) Try to fix the path (which are all the places where your computer is going to go and look for it). Check the path with this:

      echo $PATH

      which displays this (in my case. Your computer could be different):

      /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

      Think of the colons as the separators. As you can see /usr/local/bin is right there which is why my computer always finds wget.

      If the path to the folder where wget is not there just add it. Here’s an excelent source to check how to do that as there are different cases:

      http://www.troubleshooters.com/linux/prepostpath.htm

  2. #4 by Barry on April 25, 2013 - 7:18 pm

    Had the same thing when I copied and pasted straight from the page.
    Roll over the 6 numbered lines and on the right 4 icons appear, click the first one “view source” and copy the lines one at a time from there.
    I guess the copied text needs to be clean…?

    Hope that helps you too ;)

  3. #5 by Dheeraj on April 26, 2013 - 3:58 pm

    Having some issues:
    [13:52:14] dkhanna@MacBookPro1:~/Documents/abcd
    $ cd wget-1.14
    [13:52:21] dkhanna@MacBookPro1:~/Documents/abcd/wget-1.14
    $ sudo ./configure –with-ssl=openssl
    configure: configuring for GNU Wget 1.14
    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for a thread-safe mkdir -p… build-aux/install-sh -c -d
    checking for gawk… no
    checking for mawk… no
    checking for nawk… no
    checking for awk… awk
    checking whether make sets $(MAKE)… no
    checking build system type… i386-apple-darwin12.3.0
    checking host system type… i386-apple-darwin12.3.0
    checking for gcc… no
    checking for cc… no
    checking for cl.exe… no
    configure: error: in `/Users/dkhanna/Documents/abcd/wget-1.14′:
    configure: error: no acceptable C compiler found in $PATH
    See `config.log’ for more details
    [13:52:41] dkhanna@MacBookPro1:~/Documents/abcd/wget-1.14
    $ sudo make
    sudo: make: command not found
    [13:53:08] dkhanna@MacBookPro1:~/Documents/abcd/wget-1.14
    $ sudo make install
    sudo: make: command not found
    [13:53:22] dkhanna@MacBookPro1:~/Documents/abcd/wget-1.14
    $

    Can you please look at this and tell me what should i do ?
    I was able to get binary for wget from internet since i didnt wanted to install xcode. Would you be able to guide me if i can complete installation using the binary directly as thats eventually what ‘make’ creates.

    • #6 by Travis on June 19, 2013 - 12:45 pm

      Dheeraj,

      If you have obtained a pre-compiled binary for your version of OSX, you should just be able to:
      sudo cp wget /usr/local/bin
      sudo chown root:wheel /usr/local/bin/wget
      sudo chmod 755 /usr/local/bin/wget

      If you only have the wget-1.14 source (as it appears in the steps you posted), you will HAVE to install Xcode to compile it.

  4. #7 by Magnus on June 23, 2013 - 2:19 pm

    Thanks! Works perfect with Mountain Lion.
    You don’t need to download the huge 1.5GB xcode though. There is a Xcode Command Line Tools package which is enough at only 1/10 of the size.

    • #8 by Mike on June 28, 2013 - 10:54 am

      Do you have a link to the CLI tools package?

  5. #9 by David on June 23, 2013 - 7:03 pm

    Thanks for this. Worked fine for me using Mountain Lion.

  6. #10 by Maxwell Mitchell on August 2, 2013 - 5:32 pm

    I continue to get the following remark when trying to make wget commands after the downloading process…

    Bad CPU type in executable
    __________

    This is the ending of what I got after typing sudo make install:

    http-ntlm.c:286: warning: ‘MD4_Update’ is deprecated (declared at /usr/include/openssl/md4.h:114)
    http-ntlm.c:287: warning: ‘MD4_Final’ is deprecated (declared at /usr/include/openssl/md4.h:115)
    mv -f .deps/http-ntlm.Tpo .deps/http-ntlm.Po
    gcc -O2 -Wall -o wget cmpt.o connect.o convert.o cookies.o http://ftp.o css_.o css-url.o ftp-basic.o ftp-ls.o hash.o host.o html-parse.o html-url.o http.o init.o log.o main.o netrc.o progress.o ptimer.o recur.o res.o retr.o spider.o url.o warc.o utils.o exits.o build_info.o version.o ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a -liconv -lssl -lcrypto -lz -ldl -lz -lz
    ../build-aux/install-sh -c -d ‘/usr/local/bin’
    /usr/bin/install -c wget ‘/usr/local/bin’
    make[3]: Nothing to be done for `install-data-am’.
    Making install in doc
    make[3]: Nothing to be done for `install-exec-am’.
    /bin/sh /Users/maxwellamitchell/wget-1.14/build-aux/install-sh -d /usr/local/etc
    mkdir: /usr/local/etc: File exists
    make[3]: *** [install.wgetrc] Error 1
    make[2]: *** [install-am] Error 2
    make[1]: *** [install-recursive] Error 1
    make: *** [install] Error 2
    Maxwell-Mitchells-MacBook-Pro-2:wget-1.14 maxwellamitchell$

    What do I do?

  7. #11 by Amanda Simpson on September 30, 2013 - 4:49 am

    I tried your instruction but got the error -bash: wget: command not found. Same as from one above. Thanks to fellow commentators, its fixed. Great post you got.