Skip to content

Instantly share code, notes, and snippets.

@todgru
Last active December 9, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todgru/4315183 to your computer and use it in GitHub Desktop.
Save todgru/4315183 to your computer and use it in GitHub Desktop.
Notes about curl CURL cURL

#Bash and Curl

###cURL

Record an mp3 stream to a file:

$ curl http://example.com/stream.mp3 -o file.mp3

http://stream1.opb.org/kmhd_web.mp3

Options

  • -s/--silent Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute.
  • -f/--fail (HTTP) Fail silently (no output at all) on server errors...
  • -k/--insecure (SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers.

GET method

curl "http://www.hotmail.com/when/junk.cgi?birthyear=1905&press=OK"

POST method

curl --data "param1=value1&param2=value2" http://example.com/resource.cgi
curl --data-urlencode "name=I am Daniel" http://www.example.com

Post with header:

curl --header "x-myheader: my value" --data "param1=value1" http://example.com/resource.php

To post an array, use this:

curl --data "meta[key1]=value1&meta[key2]=value2" http://example.com/controller/method

See: http://curl.haxx.se/docs/httpscripting.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment