Tuesday, December 10, 2013

Mac OS X: Install wget Network Downloader Utility

recently learned that "wget" can continue getting a partially-downloaded (resume download) file. I am unable to find wget command on Mac OS X. How do I install install wget on Mac OS X (Mountain Lion/ Mavericks / Snow Leopard)? How can I install wget in Mac OS X without 3rd-party repo such as Homebrew or MacPorts?

You can install the latest version of GNU/wget and many other open source software without using Homebrew or MacPorts. The steps are as follows:

Prerequisite

You need to instal a free app called Xcode. It includes command line development tools such as gnu/gcc and friends. See how to install GCC Compiler with Xcode for more information.
Fig.01: Install gcc compiler on Mac OS X
Fig.01: Install gcc compiler on Mac OS X

Step #1: Download gnu/wget source code

Use curl command as follows to download the latest gnu/wget from the official project site. Open the Terminal and than type the following commands:
$ cd /tmp
$ curl -O http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
$ ls -l

Sample outputs:
Fig.02: Downloading wget source code with the curl utility
Fig.02: Downloading wget source code with the curl utility

Step #2: Extract files

Use the tar command to extract files on OS X as follows:
$ tar xvf wget-1.15.tar.gz
Sample outputs:
x wget-1.15/
x wget-1.15/doc/
x wget-1.15/doc/stamp-vti
x wget-1.15/doc/texi2pod.pl
x wget-1.15/doc/Makefile.in
....
..
...
x wget-1.15/NEWS
x wget-1.15/configure
x wget-1.15/ChangeLog
x wget-1.15/MAILING-LIST

Step #3: Configure, Compile and Install GNU/wget on OS X

First, cd to the wget-1.15 directory using cd command:
$ cd wget-1.15
To configure wget, enter:
$ ./configure --with-ssl=openssl
Sample outputs:
Configure: configuring for GNU Wget 1.15
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
....
..
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating doc/Makefile
config.status: creating util/Makefile
config.status: creating po/Makefile.in
config.status: creating tests/Makefile
config.status: creating tests/WgetTest.pm
config.status: creating lib/Makefile
config.status: creating src/config.h
config.status: executing depfiles commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
To compile wget on OS X, enter:
$ make
Sample outputs:
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in lib
rm -f alloca.h-t alloca.h && \
 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
   cat ./alloca.in.h; \
 } > alloca.h-t && \
 mv -f alloca.h-t alloca.h
....
..
...
gcc  -O2 -Wall   -o wget cmpt.o connect.o convert.o cookies.o 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
Making all in doc
./texi2pod.pl -D VERSION="1.15" ./wget.texi wget.pod
/usr/bin/pod2man --center="GNU Wget" --release="GNU Wget 1.14" wget.pod > wget.1
Making all in po
Making all in tests
make[2]: Nothing to be done for `all'.
Making all in util
make[2]: Nothing to be done for `all'.
make[2]: Nothing to be done for `all-am'.
To install wget, enter:
$ sudo make install

Find out wget location on OS X

By default wget will be installed at the /usr/local/bin/wget. You can use the whereis utility (or type -a) to check the wget location, enter:
$ whereis wget
OR
$ type -a wget
If you do not see output, edit $HOME/.bash_profile or $HOME/.bashrc and add/edit/append PATH as follows:
export PATH=${PATH}:/usr/local/bin
Save and close the file.

How do I use wget command?

The basic syntax is:
wget url
wget http://www.cyberciti.biz/
wget ftp://url/

To see wget version, type:
$ wget --version
Sample outputs:
GNU Wget 1.15 built on darwin13.1.0.
 
+digest +https +ipv6 -iri +large-file -nls +ntlm +opie +ssl/openssl
 
Wgetrc:
    /usr/local/etc/wgetrc (system)
Compile:
    gcc -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc"
    -DLOCALEDIR="/usr/local/share/locale" -I. -I../lib -I../lib -O2
    -Wall
Link:
    gcc -O2 -Wall -liconv -lssl -lcrypto -ldl -lz ftp-opie.o openssl.o
    http-ntlm.o ../lib/libgnu.a
 
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
 
Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>.

How do I update installed gnu/wget on OS X?

Warning: The following method only works if you installed gnu/wget earlier using source code based method as described above. Do not use the following method if you installed wget using Homebrew or MacPorts.
## Note: wget v1.16 is not released yet! This is a demo for future version ;) ###
$ cd /tmp
$ VERSION="1.16"
$ wget http://ftp.gnu.org/gnu/wget/wget-${VERSION}.tar.gz
$ tar xvf wget-${VERSION}.tar.gz
$ cd wget-${VERSION}
$ ./configure --with-ssl=openssl && make
$ sudo make install
$ wget --version

0 comments:

Post a Comment