As to emptying the nofind variable, I've always just done something like 
  nofind=  (that's just an empty = ). "unset" is probably even better...

I believe you use "trap" to catch a ctrl-c in bash, but I've never 
experimented with it. See, e.g., 
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html

I understand your motivation, but might your wife not be just as 
impressed if you did the same thing in fewer lines and easier code by 
using ruby or python? Python has standard libraries to handle getting 
and parsing (and logging in, and managing cookies) pages by URL, and I 
was told that ruby did too...

Cheers,
Vern

Jon wrote:
> 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---------------------------------------
> 

-- 
This time for sure!
    -Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
[EMAIL PROTECTED]; 260-436-0746; FAX: 260-436-5137

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

Reply via email to