Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lappy@lappy-N53SN:~$ cat /home/lappy/SignOn/checkAvailableApartments.sh
- #!/bin/bash
- #Get settings
- source /home/lappy/SignOn/config.sh
- WGET="wget -q"
- #Get the session id from the hidden field
- SESSION_ID=$($WGET https://sso.sdu.dk/login -O - | grep -o -P '(?<= name="lt" value=").*(?=")')
- #Let's login and get the cookie
- LOGIN_RESPONSE=$($WGET --post-data "auth=MAD&it=$SESSION_ID&madusername=$USER_NAME&madpassword=$USER_PASSWORD" "https://sso.sdu.dk/login?service=https%3A%2F%2Fhousingapplication.sdu.dk%2FSSO.aspx" -O -)
- #Let's visit the url with the token as GET parameter
- REDIRECT_URL=$(echo $LOGIN_RESPONSE | grep -oP 'href="(.*?)"' | head -n 1 | sed -e 's/href="//g;s/"//g' )
- #We just do this to get the cookie
- $WGET --keep-session-cookies --save-cookies cookies.txt --max-redirect 0 $REDIRECT_URL -O /dev/null
- #Load the housing application to get current status
- APARTMENT_AVAILABLE=$($WGET --load-cookies cookies.txt "https://housingapplication.sdu.dk/" -O -)
- if [ $(echo $APARTMENT_AVAILABLE | grep -i "optaget" | wc -l ) == "1" ]; then
- echo "Still occupied.."
- else
- echo "must be available! let's inform me"
- python /home/lappy/SignOn/sendmail.py
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement