#!/bin/bash
#
# This script uses statserial to check the Ring Indicator signal of a
# modem. If the phone rings, it displays a message.
#
while true
do
  let ringing="`statserial -d /dev/modem` & 128"
  if [ $ringing != 0 ]
  then
    # can either send message to standard out
    echo -e "\a(`date`) Incoming Telephone Call"
    # or send mail
    # echo "Incoming phone call detected." | mail -s "Incoming Phone Call" `whoami`
    sleep 10
  fi
  sleep 1
done
