Skip to content

Instantly share code, notes, and snippets.

@cnandreu
Created December 16, 2011 23:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnandreu/1488556 to your computer and use it in GitHub Desktop.
Save cnandreu/1488556 to your computer and use it in GitHub Desktop.
Bash: Get grades from home.uprm.edu
#!/bin/bash
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <carlos.andreu[at]upr.edu> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.
# ----------------------------------------------------------------------------
#Your home.uprm.edu login goes here:
name=nombre.apellido
pass=12345
#This will run every hour until you close it manually (ctrl+c)
while true; do
#Get the session cookie
wget --save-cookies cookies.txt \
--keep-session-cookies \
--post-data "username=$name&password=$pass" \
https://home.uprm.edu/ckstart.php
#Get the grade picture
wget --load-cookies cookies.txt \
--keep-session-cookies \
-p https://home.uprm.edu/grades/students/view.php
#Move it to relative root
cp home.uprm.edu/grades/students/card.php\?l\=* grades.png
#Chill
sleep 1
#Clean up
rm cookies.txt ckstart.php
rm -rf home.uprm.edu/
#Compare md5 hashes
md5 grades.png >> md5.txt
if [ -f old_md5.txt ]
then
diff md5.txt old_md5.txt >> result.txt
fi
mv md5.txt old_md5.txt
#result.txt exists and is greater than 0
if [ -s result.txt ]
then
growlnotify -m "New grade!"
rm result.txt
fi
#3600 seconds = 1hour
sleep 3600
done
@edwinfg
Copy link

edwinfg commented Dec 22, 2011

It works perfect with Ubuntu 11.04, just two changes. It is very likely that any distribution of Linux also work.

  1. md5 <--> md5sum
  2. growlnotify -m <--> xmessage -center

Good job, Carlos.

@cnandreu
Copy link
Author

Thanks!

@santuche
Copy link

Thanks a lot, I had a problem with the growlnotify part using mac (I think bad installing), but I changed that part and I used the command "afplay victory.mp3" and it's works, every time that I get a new Grade, the music of "Victory" is played.

Thanks for the script

@cnandreu
Copy link
Author

Nice to hear, thanks for leaving feedback! :]

@cesarandreu
Copy link

Since I'm using Mountain Lion, I don't have Growl anymore. So I downloaded Terminal Notifier (https://github.com/alloy/terminal-notifier) and it seems to be working fine.

Just replace growlnotify -m with terminal-notifier -message.

@lmendezr
Copy link

lmendezr commented Dec 9, 2013

Made it work on Windows! Here's a small tutorial:

  1. Get Cygwin, and install it with both wget and diffutils.
  2. Download Notifu for Windows: http://www.paralint.com/projects/notifu/#Download (unzip it in the home folder Cygwin made for you. Hint: it's over at Cygwin's install folder.)
  3. Download my modded version of the uprmGradeStalker.sh: https://dl.dropboxusercontent.com/u/23501115/uprmGradeStalker.sh (only added ~ to the cp command and --no-check-certificate)
  4. Execute it from Cygwin.

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment