#!/bin/sh
# audioping host
# Ping a host, make a noise for each packet received.
# Useful for network debugging.
# Works on Sparcstations and Nexts.
#
# Be sure to uncomment the appropriate 'makenoise' line, depending
# on whether you want a simple ^G beep or a more complex sound.
#
# Steve Hayman
# Indiana University
# sahayman@cs.indiana.edu
# Tue Feb 19 16:06:00 EST 1991

PATH=/etc:/usr/etc:/bin:/usr/bin:/usr/ucb export PATH

case "$#" in
1) 	;;
*)	echo "$0: Use: $0 hostname" 1>&2; exit 1 ;;
esac

# Set the 'makenoise' variable to some sort of program
# that makes a noise.  This can be whatever you want,
# but if the noise is more than 1 second long you'll have problems
# with timing getting out of sync.


# On a plain ordinary terminal, make a noise by echoing a control-G.
# (We do it this way so that we don't have to put a literal ^G in this file.)
makenoise='echo -n . | tr . \\07'

# On a Sun, if you have an appropriate sound file, you can make
# a noise this way:
# makenoise="cat /some/sound/file >/dev/audio"


# On a NeXT you can play a sound file this way.
# Try running "snrdrecord some-file.snd", hit RETURN,
# say "PING" into the microphone, hit RETURN again.
#
# makenoise="sndplay some-file.snd"

ping -r -s $1 | tee /dev/tty | while read line; do
    case "$line" in
    *icmp*)	eval $makenoise ;;
    esac

done


