Created
December 16, 2011 23:43
-
-
Save cnandreu/1488556 to your computer and use it in GitHub Desktop.
Bash: Get grades from home.uprm.edu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Thanks!
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
Nice to hear, thanks for leaving feedback! :]
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
.
Made it work on Windows! Here's a small tutorial:
- Get Cygwin, and install it with both wget and diffutils.
- 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.)
- 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)
- Execute it from Cygwin.
Enjoy!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works perfect with Ubuntu 11.04, just two changes. It is very likely that any distribution of Linux also work.
Good job, Carlos.