#! /bin/csh -f
#
#  this sends the location of the current PPP connection
#


set tmp=/tmp/ppp.$$
set ppp=ppp0

foreach i (1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0)
  /sbin/ifconfig | grep -q $ppp
  set s=$?
  if ($s == 0) then
    set ip=`/sbin/ifconfig $ppp | grep add | awk '{print $2}' | awk -F: '{print $2}'`
    if ($#argv > 0) then
        echo `date` | mail -s "PETER: $ip" $1 
    else
        echo We are $ip
    endif
    exit 0
  endif
  sleep 10
end

echo `date` | mail -s "PPP: bad connect" teuben
