A script that uses wget to login/logout at phpbb board

This is only an example of using of wget to validate a login session:

#!/bin/sh
# phpbb-auto-login.sh copyleft Fabio Z 2009
# login & logout user to phpBB forum boards
 
 
if [ $# -le 1 ] || [ $# -gt 3 ]; then
 echo "Usage $0 URL user pass --> to login"
 echo "Usage $0 URL user      --> to logout"
fi
 
PHPBB_URL=http://$1
USER=$2
PASS=$3
 
 
#--------------------------- login ---------------------------
if [ $# -eq 3 ] ; then
 
 wget --save-cookies=./session-cookies-$USER $PHPBB_URL/ucp.php?mode=login -O - 1> /dev/null 2> /dev/null
 
 SID=`cat ./session-cookies-$USER | grep _sid | cut -d$'\011' -f7`
 
 echo "Login $USER --> $PHPBB_URL SID=$SID"
 
 wget --save-cookies=./session-cookies-$USER \
 --post-data="username=$USER&password=$PASS&redirect=index.php&sid=$SID&login=Login" \
 $PHPBB_URL/ucp.php?mode=login --referer="$PHPBB_URL/ucp.php?mode=login" \
 -O - 1> /dev/null 2> /dev/null
 
fi
 
 
#-------------------------- logout --------------------------
if [ $# -eq 2 ] ; then
 
 
 SID=`cat ./session-cookies-$USER | grep _sid | cut -d$'\011' -f7`
 
 echo "Logout $USER <-- $PHPBB_URL SID=$SID"
 
 wget --load-cookies=./session-cookies-$USER "$PHPBB_URL/ucp.php?mode=logout&sid=$SID" --referer="$PHPBB_URL/index.php" -O -  1> /dev/null 2> /dev/null
 
fi
Retrieved from "http://www.zoros.org/wiki/index.php?title=A_script_to_login_phpbb_forum_using_wget"