AMITIAE - Tuesday 9 October 2012


Command Line Work: New Users and Terminal (13) -- Installing and Using the Utility, WGET


apple and chopsticks



advertisement


By Graham K. Rogers


Terminal


Ever since the first Macs appeared, they have been known for the graphical user interface (GUI): icons instead of command line work which before the mid-1980s was the norm. Paradoxically, the arrival of OS X brought with it easy access to the command line should users ever want this, although it is possible to use the computer without ever needing to work at the command line at all.


A few years ago, when bandwidth was far more precious than it is these days, I used a utility to download web pages and read them offline. The utility was wget and although I had used this on earlier versions of OS X, it was not available when I checked my current Mountain Lion installation (OS X, 10.8) on the office iMac. I decided to reinstall the utility anew.


Downloading and Installing

A search of the internet gave me a number of sources and some useful information for using the utility. Mac Tricks & Tips has a page on compiling this from the binary files, as does Hack Sparrow (delightful name).


I finally downloaded the requisite files from Status-Q where there is a clear explanation on the web page as well as in a Readme file with the download: a ZIP file of some 275 KB.

There are three files in the package and the instructions are to place

  • wget into /usr/local/bin
  • wget.1 into /usr/local/man/man1
  • wgetrc into /usr/local/etc


    The problem for me was that not all of the folders existed, so as I outlined in an earlier article, I had to use the mkdir command. As the /usr/local folder is owned by Root, the command needed to be preceded by sudo so the wget utility could only be installed from within the Admin account on my computer.


    Using WGET

    Once installed, the utility can be run in a user account. It is just the install that has to be done in Admin. There is no manual entry for wget, however there is a help file

    wget --help

    which reveals a number of useful commands that can be used. Particularly useful is the -O option which specifies the filename to write to. I selected a folder and dragged it into the Terminal command line, then added a name: the file was created when I used the command.

    Some sites will not allow the wget command to be used: my own site for example. The host service blocks this, so entering the command,

    wget -l inf http://www.extensions.in.th/teaching (for an infinite number of levels),

    will display a 403 forbidden message,


    graham$ wget -l inf http://www.extensions.in.th/teaching
    --2012-10-08 22:25:26-- http://www.extensions.in.th/teaching
    Resolving www.extensions.in.th... 64.202.33.80
    Connecting to www.extensions.in.th|64.202.33.80|:80... connected.
    HTTP request sent, awaiting response... 301 Moved Permanently
    Location: http://www.extensions.in.th/teaching/ [following]
    --2012-10-08 22:25:27-- http://www.extensions.in.th/teaching/
    Connecting to www.extensions.in.th|64.202.33.80|:80... connected.
    HTTP request sent, awaiting response... 403 Forbidden
    2012-10-08 22:25:27 ERROR 403: Forbidden.


    I was however able to use this on others, including the Status-Q site and the page displayed nicely in WriteRoom:


    wget


    There is also a page on The Geek Stuff that outlines 15 wget examples, including how to download a full website, with the wget --mirror command.

    The commands on that page may simply be copied and pasted into the Terminal command line, or adapted for a user's specific needs.

    As ever, If in doubt, Don't.


    To be continued. . . .



    See Also -

  • New Users and Terminal (1) -- A Quick Look Round
  • New Users and Terminal (2) -- Basic Navigation
  • New Users and Terminal (3) -- Shell Basics
  • New Users and Terminal (4) -- Lists and Manuals
  • New Users and Terminal (5) -- Internet Use
  • New Users and Terminal (6) -- Questions of Identity
  • New Users and Terminal (7) -- A Little More Discovery
  • New Users and Terminal (8) -- File Commands and More
  • New Users and Terminal (9) -- Process Identification and Termination
  • New Users and Terminal (10) -- Browsing the Web using Unix
  • New Users and Terminal (11) -- Unix Tricks from OS X Daily
  • New Users and Terminal (12) -- Installed Text Editors - emacs, nano, pico, vi and vim
  • New Users and Terminal (14) -- Passwords, Purging and Closing Notes
  • New Users and Terminal (15) -- Permissions and chmod


    Graham K. Rogers teaches at the Faculty of Engineering, Mahidol University in Thailand. He wrote in the Bangkok Post, Database supplement on IT subjects. For the last seven years of Database he wrote a column on Apple and Macs.


  • advertisement



    Google


    Made on Mac

    For further information, e-mail to

    information Tag information Tag

    Back to eXtensions
    Back to Home Page