1: #!/usr/bin/tcl 2: # Change this to what you want to be executed, \$IP being the new IP 3: set Execute "echo \$IP | mail joo@schmoo" 4: 5: set NewIp "0.0.0.0" 6: set iface 0 7: while {1} { 8: set meep [split [exec /sbin/ifconfig] \n] 9: foreach mp $meep { 10: if {[string range [lindex $mp 0] 0 2]=="ppp"} { set iface 1 } 11: if {[lindex $mp 0]=="inet" && $iface} { 12: set word [split [lindex [split [lindex $mp 1] :] 1] .] 13: set OldIp $NewIp 14: set NewIp "[lindex [split [lindex $mp 1] :] 1]" 15: set IP $NewIp 16: if {$OldIp != $NewIp} { 17: catch { system [subst $Execute] } 18: } 19: set iface 0 20: } 21: } 22: sleep 60 23: } pppchange.tcl is a Tcl script I wrote to email you when your PPP IP changes. |