Skip to content

Instantly share code, notes, and snippets.

@espaciomore
Last active March 3, 2017 22:12
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 espaciomore/cbbbe4675f9e920a8704a6d23bcc6550 to your computer and use it in GitHub Desktop.
Save espaciomore/cbbbe4675f9e920a8704a6d23bcc6550 to your computer and use it in GitHub Desktop.
Login using Curl saving cookies file
#!/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