Last active
March 3, 2017 22:12
-
-
Save espaciomore/cbbbe4675f9e920a8704a6d23bcc6550 to your computer and use it in GitHub Desktop.
Login using Curl saving cookies file
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/bash | |
#TIMESTAMP=`date "+%Y%m%d_%H%M%S"` | |
FILTER="<title>" | |
REPLACEMENT="s/\s*<\/?title>\s*//g" | |
RESOURCE1="" | |
RESOURCE2="" | |
function get_cookie { | |
echo "POST $1/$RESOURCE1" | |
curl -d "$2" -H "Content-Type: application/x-www-form-urlencoded" -X POST "$1/$RESOURCE1" -s -c "cookie" | |
curl "$1/$RESOURCE2" -s -b "cookie" | egrep "$FILTER" | sed -re "$REPLACEMENT" | |
} | |
# $1 server-url | |
# $2 login-credentials | |
if [ -n "$1" ] && [ -n "$2" ]; then | |
get_cookie "$1" "$2" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment