Wednesday, February 17, 2010

wget or curl

This is not a comparison between the two tools but rather how to get them working the same way when requesting for example Web Services.

So here we are trying to test our super cool and light  JSON Service from the command prompt and curl comes to our rescue:
$ curl http://my-app.com/default/login?ert=json
Wget will need a couple of switches to provide the same output (for more info: wget --help):
$ wget -q -O - http://my-app.com/default/login?ert=json
Let's say you want to download a file. With wget you go this way:
wget -o http://google.com/images/srpr/logo4w.png
With curl you go with the below. Note the -L switch to make sure curl follows redirections:
curl -L -o logo4w.png http://google.com/images/srpr/logo4w.png

No comments:

Followers