Last active
August 29, 2015 14:10
-
-
Save garystafford/0f019b32d286bcbcdd29 to your computer and use it in GitHub Desktop.
Generate article data for MEAN.io apps using curl
This file contains 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/sh | |
# Generate article data for MEAN.io app | |
# Requires curl | |
# You need authenticated session to run script. | |
# Log into MEAN.io app with a user and grab cookie connect.sid value for sid variable! | |
# Format of binary data: --data-binary '{"title":"foo", "content":"bar..."}' | |
# User-defined variables | |
messages=200 | |
sid="s%3AOUewK2gwcgpmbi2DNjG4PBNxjGVuwyQY.eI5B55LCPs%2B%2B6kpaocbOi5NBVAaZS%2FW%2BkQ9%2Fo8QSsMk" | |
url="http://localhost:3000/articles" | |
count=1 | |
while [ $count -le $messages ] | |
do | |
timestamp=$(date +%s) | |
bin_data="{\"title\":\"Test Article $count ($timestamp)\", \"content\":\"Here are the contents of 'Test Article $count ($timestamp)'...\"}" | |
curl "$url" \ | |
-H "Content-Type: application/json;charset=UTF-8" \ | |
-H "Cookie:connect.sid=$sid" \ | |
--data-binary "$bin_data" \ | |
--compressed | |
count=`expr $count + 1` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment