Tuesday, February 9, 2010

Using CURL with cookies and authentication

The script is as follows.... Just replace URL, user and password with the appropriate strings.

#!/bin/bash
# Acquire RAT Page cookie
curl \
--trace-ascii curl1.log \
-c cookies.txt \
URL
#
# Sleep 2 seconds for operation to complete
sleep 2
#
# Acquire actual RAT Home Page using cookie
curl \
--trace-ascii curl2.log \
-b cookies.txt \
-u username:password \
URL
#
echo "Done"