Created
July 23, 2017 20:06
-
-
Save simongle/adffe56c27c0c0c543e1133b77e1a049 to your computer and use it in GitHub Desktop.
Bash script for reading data from JSON and posting it to a CMS using automated cURL requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
length=$(jq 'length' new_ids.json) | |
for i in `seq $length`; do | |
name=$(jq '.['"$i"'].name' new_ids.json | sed 's/.$//' | sed 's/^.//') | |
password=$(jq '.['"$i"'].password' new_ids.json | sed 's/.$//' | sed 's/^.//') | |
email=$(jq '.['"$i"'].email' new_ids.json | sed 's/.$//' | sed 's/^.//') | |
chapter_id=$(jq '.['"$i"'].chapter_id' new_ids.json | sed 's/.$//' | sed 's/^.//') | |
echo $email | |
echo $chapter_id | |
curl 'http://www.afsusa.org/direct' -H 'Cookie: [cookie_data]' -H 'Origin: http://www.example-site.org' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: */*' -H 'Referer: http://www.example-site.org/site_admin/change_site/75' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'extTID=10&extAction=Chapteruser&extMethod=save&extType=rpc&extUpload=false&id=' --compressed -d "name=${name}" -d "email=${email}" -d "password=${password}" -d "chapter_id=${chapter_id}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment