Skip to content

Instantly share code, notes, and snippets.

@xkeshav
Created July 7, 2017 15:41
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 xkeshav/2fda262372f8795769777651f368b655 to your computer and use it in GitHub Desktop.
Save xkeshav/2fda262372f8795769777651f368b655 to your computer and use it in GitHub Desktop.
run curl from a file with parameter as post data and variable such as current date, random number
#!/bin/bash
# call as `sh curl.sh <uuid> <hostname>`
# exmaple sh curl.sh 595e341fd7391071d21ce1b5 20.20.1.73
header="Content-Type: application/json"
enc=$(shuf -i 0-1000 -n 1)
dec=$(shuf -i 10-600 -n 1)
now=$(date +%s%3N)
post_data=$(cat <<EOF
{
"ip_address": "$2",
"baffleShield_id": "$1:CompareServer-0",
"num_records_1": $enc,
"num_records_2": $dec,
"epoch_time": $now
}
EOF
)
echo "$post_data"
curl -k -X POST -H "$header" -d "$post_data" http://127.0.0.1:8553/whatever/url/$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment