Last active
August 29, 2015 13:57
-
-
Save scottcagno/9510912 to your computer and use it in GitHub Desktop.
simple curl wrapper to aid in web testing
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 | |
| # File: crawl.sh | |
| # Desc: Package designed to provide an API to help automate web testing | |
| # Dependencies: curl, getopts | |
| # Copyright 2014, Scott Cagno, All rights reserved. | |
| # usage function | |
| function usage() { | |
| echo -e "usage: $0 <opts> -h [host-uri]" | |
| echo -e " opts:" | |
| echo -e " -c enable cookie handling" | |
| echo -e " -f submit form data (uses post implicitly)\n" | |
| exit 1 | |
| } | |
| # parse command line options | |
| while getopts "cf:h:" flag; do | |
| case "${flag}" in | |
| c) | |
| EPOCH_DAY=$(( `date +%s` / 60 / 60 / 24 )) | |
| ARGS=$ARGS" -c cookie-$EPOCH_DAY.txt -b cookie-$EPOCH_DAY.txt" | |
| ;; | |
| f) | |
| ARGS=$ARGS" -d ${OPTARG}" | |
| ;; | |
| h) | |
| h=${OPTARG} | |
| HOST=$h | |
| ;; | |
| *) | |
| usage | |
| ;; | |
| esac | |
| done | |
| shift $((OPTIND-1)) | |
| # check to ensure host | |
| if [ -z "${h}" ]; then | |
| usage | |
| fi | |
| # issue request | |
| curl -k $ARGS $HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment