I've a attached a script that I wrote to do this. I assume
that's what you meant by implementing it. If not, then hey, free
code. And as far as the previous email go, you should put it
in the rc.d scripts. I would add it just after the point in
the script where you bring up the relevant interface.
> I would like to have my computer send an email to my ut address
> everytime it boots up containing it's ip in the body (or at least
> subject) of the message. I figure I'd use cron to do it but I am not
> sure how to implement it. Any suggestions?
#!/bin/sh
#
# ipnotify: sends ip address to email address if it changes
#
# this needs some work to make it elegant, but it works
# as a hack by a lazy college student.
$dir=<dir to put file with ip info>
$fromaddr=<address in from: line of email>
$toaddr=<email addr to send ip to>
# move old ip to another file for diff purposes
mv -f $dir/ipaddr $dir/ipold
# grab ip info out of ifconfig -- this must be modified,
# depending on which device's ip you care about and where
# that device appears in the ifconfig output
ifconfig | awk '/inet/ {print $0}' | tail -2 | head -1 > $dir/ipaddr
# diff the two ips, and send it to me if they differ.
if [ "`diff /$dir/ipaddr $dir/ipold`" != "" ]; then
diff $dir/ipaddr $dir/ipold
sendmail -f $fromaddr $toaddr < $dir/ipaddr
fi