#!/usr/local/bin/expect # # This script pings a list of hosts. # If any are down, it pages the system admin. # # Don # # Note: you'll need to customize this for your pager. This should be pretty # easy, but if you need help, look at some of the pager-specific scripts in # the Expect scripts archive. ############################# # attempt to ping each host # ############################# foreach host $argv { spawn ping $host set timeout 2 expect "alive" {continue} timeout { lappend deadhosts $host } close wait } ########################## # send message via pager # ########################## if [info exists deadhosts] { spawn tip modem expect "connected" send "ATD1234567\r" expect "user:" send "user123\r" expect "msg:" send "not responding to ping: $deadhosts\r" expect eof }