Created
October 9, 2012 17:22
-
-
Save daniel-fanjul-alcuten/3860173 to your computer and use it in GitHub Desktop.
the giri of the day
This file contains hidden or 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 | |
# installation procedure: | |
# | |
#$ aptitude install qdbm-util | |
#$ { | |
# crontab -l | |
# echo '1 0 * * 1-5 [email protected] ~/bin/tgotd.sh' | |
#} | crontab | |
file=${FILE:-~/etc/tgotd.dp} | |
email=${EMAIL:-dfanjul+giris@somewhere.com} | |
if ! [ -f "$file" ]; then | |
dpmgr create "$file" | |
fi | |
function ikey() { | |
if ! dpmgr get "$file" "$1" >/dev/null 2>&1; then | |
dpmgr put "$file" "$1" 0 | |
fi | |
} | |
ikey fulanito | |
ikey menganito | |
giri=`dpmgr list "$file" | sort -k2 -n | head -1 | cut -f1` | |
subject="The giri of today is $giri [EOM]" | |
echo "$subject" | |
mail -s "$subject" "$email" < /dev/zero 2>/dev/null && \ | |
dpmgr put "$file" "$giri" `date +%s` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I really prefer python:
import os, random
users = ['fulanito', 'menganito']
giri = random.choose(users)
os.system('mail -s "The giri of today is {} [EOM] < /dev/zero 2>/dev/null'.format(giri))
It is soooooo beautiful....