How can I do an HTTP GET from a Un.x shell script on a stock OS X system? (installing third-party software is not an option, for this has to run on a lot of different systems which I don't have control on).For example if I start the Mercurial server locally doing a hg serve. $ hg serveAnd then, from a Linux that has the wget command I do a wget. $ wget 22:18:25- to 127.0.0.1:8000. Connected.HTTP request sent, awaiting response. 200 Script output followsLength: unspecified text/htmlSaving to: `index.htmlAnd on the terminal in which I launched the 'hg serve' command, I can indeed see that an HTTP GET made its way: 127.0.0.1 -30/Dec/2010 22:18:17 'GET / HTTP/1.0' 200 -So on Linux one way to do an HTTP GET from a shell script is to use wget (if that command is installed of course).What other ways are there to do the equivalent of a wget?
![]()
Wget for Mac Free Download: Wget for Mac is a unique tool with which you can easily retrieve the files from the web servers with ease. Wget Mac PC app supports retrieving the files using the most familiar internet protocols including the HTTP, HTTPS, FTP and FTPS. It is not only a free software package but is also a non-interactive command-line tool that will help you retrieve file easily. Wget is a small program that can download files and folders to your computer through Terminal. There is already program similar to wget on your Mac, it is called curl. Although they do the same task, I prefer wget.
I'm looking, in particular, for something that would work on stock OS X installs.
macOS Mojave, Sierra, and earlier versions come with the command line utility called ‘curl‘ which is a network transfer tool, it does not come with the popular ‘wget‘, in fact, ‘curl‘ can probably get you by just fine, check man curl at the command line to see its usage.
Otherwise, let’s look at getting ‘wget‘… this can be done in 3 ways.
1 – Install as Point and Click
Download and run the package from Rudix
2 – Compile from Source
To add and install wget to your system you need to download the source files, compile the code and make an install. To compile the code you need a compiler, unfortunately, it doesn’t come with macOS by default you need to install the free Xcode suite from Apple which includes the GCC compiler. This process also works exactly the same in previous macOS and OSX versions.
Get Xcode
Get the latest via Xcode via iTunes.
![]()
Next you need to install the Xcode command line tools, easiest way to do so by running in the Terminal:
Using curl to get wget
Get the latest wget source code from the ftp repository, or using curl from the command line:
Extract it and move into itConfigure and Install it
an error may occur on SSL…
wget needs to have some type of SSL support GNUTLS is most probably not available on your OS X system – if so use OpenSSL in the configure as an alternative use so re-run the configure with an SSL flag:
That’s it done, wget will be installed in:
Clean Up
Remove the source code and compressed file:
![]()
Test wget
Everything should work out fine – if you need to install more Unix style tools it will be faster and better to install a Package Manager for OSX like Homebrew – it makes installing and maintaining these applications so easy,
3 – Install from HomeBrew![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |