I wrote this script to help my wife know when jobs were available in
that FWCS uses to post jobs for its subs. I did this to learn my way
around curl, bash scripting, and for some sick reason my wife thinks its
hot when I do my hacking on the command line.

The script takes a username and PIN as its arguments. It hits the login
page for the service, grabs a GUID (same as the session token in the
cookie I think), a hidden foil on the form (input-form validation I
think), 

I'm missing two parts. One is to clear out the variable that I set after
checking for the errored message, the other is to properly handle
signals (like Ctrl-C) and cleanup my temp files.

Can anyone make some suggestions as to how to solve those two issues?

General comments/suggestions/improvements are also welcome. 

This is published under the WTFPL, so if you're a FWCS sub using Aesop
feel free to have a whack with this script.

-----------CODE BEGINS---------------------------------------
#! /bin/bash
#            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
#                    Version 2, December 2004 
#
# Copyright (C) 2008 Jon Bartels <[EMAIL PROTECTED]>
# Everyone is permitted to copy and distribute verbatim or modified 
# copies of this license document, and changing it is allowed as long 
# as the name is changed. 
#
#            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
#   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 
#
#  0. You just DO WHAT THE FUCK YOU WANT TO.

#make the initial request
curl https://aesoponline.com/login.asp -k --silent > /tmp/aesop

#fetch the GUID from the form target
guid=$(grep GUID /tmp/aesop | cut -d '"' -f 6 | cut -d '=' -f 2 | cut -d
'&' -f 1)

#fetch the foil from the hidden form tags
foil=$(grep foil /tmp/aesop | cut -d '"' -f 4)

echo $guid
echo $foil

#use our GUID and foil to log in
curl https://aesoponline.com/login.asp -k --silent -d GUID=${guid} -d
pswd= -d location= -d qstring= -d absr_ID= -d foil=${foil} -d id=${1} -d
pin=${2} -A Mozilla/4.0 -d submit=Sign+In -c /tmp/aesop_cookies
> /tmp/aesop

#test success
login=$(grep 'sub_default.asp' /tmp/aesop)
echo $login

#if successful the login redirects us to this page with a link (rather
than a 302, wankers)
curl 'https://aesoponline.com/subweb/sub_default.asp?GUID=
${guid}&setcookie=true' -k --silent -b /tmp/aesop_cookies 

#loop
while [ true ]; do 
        #hit the search page
        curl 'https://aesoponline.com/subweb/sub_searchforjobs.asp?GUID=
${guid}' -k --silent -b /tmp/aesop_cookies > /tmp/aesop

        #check for failure message
        nofind=$(grep 'All qualifying absences are currently filled. However,
please review this web site periodically for new job
listings.' /tmp/aesop  | cut -d '>' -f 15  | cut -d '<' -f 1)
        echo $nofind

        #beep if not failed
        if [ -z "$nofind" ]; then
                echo "JOB FOUND!!!"
                beep -r 5
        fi
        
        #not sure if this is right
        #I want to ensure that nofind is nullified/cleared/empty or otherwise
unable to meet the if condtion for the next pass on the loops
        nofind=$('')

        #spit out the date so we know when it last ran
        date
        #wait 15 minutes
        sleep $((60*15))

        #catch SIG
        #trap break SIGINT SIGTERM SIGKILL
done

#cleanup
rm /tmp/aesop_cookies
rm /tmp/aesop
-----------CODE ENDS---------------------------------------

-- 
--
Jon Bartels
[EMAIL PROTECTED]


_______________________________________________
Fwlug mailing list
[email protected]
http://fortwaynelug.org/mailman/listinfo/fwlug_fortwaynelug.org

Reply via email to