Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active August 29, 2015 14:10
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 garystafford/0f019b32d286bcbcdd29 to your computer and use it in GitHub Desktop.
Save garystafford/0f019b32d286bcbcdd29 to your computer and use it in GitHub Desktop.
Generate article data for MEAN.io apps using curl
#!/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