Voicemail notification
Whenever we get voicemail at home, MCI sends an email to whatever address I specify. This is great, but I don't recognize most phone numbers. So, today I got the great idea to write a script that takes the inbound number, looks it up in an SQL database, and then sends the name to my cell phone. This is extremely cool; then I was able to import the names from my address book into the database. I learned out php, sed, and SQL in this particular exercise.I'm glad that I have the knowledge to learn whatever I need to in order to make technology work for me.
I used 2 scripts, the first is called from /etc/mail/aliases as in:
vm_notify: "|/usr/local/bin/vmnotify_stage1",
Where vmnotify_stage1 is:
#!/bin/sh sed ' { /You have received/!d h s/You have received a Voicemail message from // h s/.// }' | /usr/local/bin/vmnotify_stage2
and
vmnotify_stage2 is:
#!/usr/bin/php -q 0) { while ($qry = mysql_fetch_array($result)) { $text = $text . "$qry[name] ($qry[phone_number])n"; } } else { $text = $phone_number; } mail("example@example.com","Voicemail from:", $text); mysql_close(); ?>
This may not be the most efficient way, but it appears to work.