Skip to content

Instantly share code, notes, and snippets.

@chrisallenlane
Created April 25, 2014 16:59
Show Gist options
  • Save chrisallenlane/11296260 to your computer and use it in GitHub Desktop.
Save chrisallenlane/11296260 to your computer and use it in GitHub Desktop.
Use cURL to POST data to a URL
#!/bin/sh
# specify the target URL
url="http://www.example.com"
# spoof a user-agent if you need to
userAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36"
# specify the payload data
data="id=12345"
data="$data&foo=bar"
data="$data&baz=bat"
# POST the payload
echo $data | curl --data @- -v -A "$userAgent" $url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment