Skip to content

Instantly share code, notes, and snippets.

@becxer
Last active August 29, 2015 14:22
Show Gist options
  • Save becxer/856a0e70af5de417e5f2 to your computer and use it in GitHub Desktop.
Save becxer/856a0e70af5de417e5f2 to your computer and use it in GitHub Desktop.
web api auto requester
#!/bin/bash
#
# web api auto requester
#
# @author becxer
# @email [email protected]
#
if [ $# -le 1 ]
then
echo ""
echo "usage :: ./reqdemon.sh <url> <apifile>"
echo ""
echo "example of <apifile> ----"
echo " url-segment/api"
echo " url-segment/api?param=0"
echo " url-segment/api?param=0 -post hello=1&world=2"
echo "-------------------------"
exit 1
fi
url=$1
filename=$2
count=0
declare -a arrapi
while read line
do
echo "$count:$line"
arrapi[$count]=$line
let count++
done <<< "$(cat $filename)"
while true; do
echo ""
echo "-----------------------------------"
for api in "${arrapi[@]}"; do
echo ""
echo "@@@@"
echo "wget $url/api/$api"
wget -q -O - "$@" $url/api/$api
done
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment