Hack 17. Greet Callers Differently Each Day
Many voicemail systems let you use a different greeting depending on the day of the week or the time of day, but not Phlinkthat is, unless you know how to use cron.
As you know from "Let Your Mac Answer and Log Your Calls" [Hack #15], a file in the /Library/Application Support/Phlink Items directory contains your outbound greeting. Either it's greeting.txt (for a synthesized voice greeting), or it's an audio file in the form of greeting.aif or greeting.mp3. But suppose you want to use a different greeting depending on the day of the week.
Thank goodness for cronthe trusty Unix relic is a workhorse. Assuming you have all of your daily greetings stored in the same place, you can create a script that cron can use to update the greeting based on the day of the week. Here's the directory listing on my machine:
Mac-Mini:/Library/Application Support/Phlink Items kelly$ ls -al total 328 drwxr-xr-x 10 tedwalli admin 340 Jun 9 22:39 . drwxrwxr-x 16 root admin 544 Jun 6 19:50 .. -rw-r--r-- 1 tedwalli admin 6148 Jun 6 19:50 .DS_Store -rw-r--r-- 1 tedwalli admin 94 Jun 6 19:50 greeting.txt -rw-r--r-- 1 tedwalli admin 755002 Jun 9 22:39 greeting_friday.aif -rw-r--r-- 1 tedwalli admin 740222 Jun 9 22:39 greeting_monday.aif -rw-r--r-- 1 tedwalli admin 700101 Jun 9 22:39 greeting_thursday.aif -rw-r--r-- 1 tedwalli admin 694450 Jun 9 22:39 greeting_tuesday.aif -rw-r--r-- 1 tedwalli admin 801006 Jun 9 22:39 greeting_wednesday.aif -rw-r--r-- 1 tedwalli admin 154102 Jun 6 19:41 ring.aif
Now, create a quick shell script like this one, for each day of the week:
#!/bin/sh ## This script is for Monday. cd "/Library/Application Support/Phlink Items" cp f greeting_monday.aif greeting.aif
Save each daily shell script in a convenient place, perhaps in a cronjobs folder in the user profile of that phlink user we made in "Run Phlink Even When Logged Off" [Hack #16]. Don't forget to make them executable (run chmod 755 * in the directory where you've put them). Then, add each file to the last column of the /etc/crontab file, which defines scheduled Unix activities that should run in the background on Mac OS X. In this example, the daily file rotation occurs at 6:30 a.m. from Monday through Friday (the Friday greeting remains in place until Monday morning):
# cron jobs to rotate the phlink greeting 30 6 * * fri ~phlink/cronjobs/Friday.sh 30 6 * * mon ~phlink/cronjobs/Monday.sh 30 6 * * tue ~phlink/cronjobs/Tuesday.sh 30 6 * * wed ~phlink/cronjobs/Wednesday.sh 30 6 * * thu ~phlink/cronjobs/Thursday.sh
Now, your Phlink setup will have a different greeting depending upon the day of the week.