home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2795 < prev    next >
Encoding:
Internet Message Format  |  1991-02-20  |  3.5 KB

  1. From: sahayman@iuvax.cs.indiana.edu (Steve Hayman)
  2. Newsgroups: alt.sources
  3. Subject: audioping: a useful hack for network debugging
  4. Message-ID: <1991Feb19.210706.24496@news.cs.indiana.edu>
  5. Date: 19 Feb 91 21:06:58 GMT
  6.  
  7. Here is a quick hack I dreamed up one night when we were
  8. having network problems on the thinwire in our office.
  9.  
  10. This simple script will "ping" another host, and make an appropriate sound
  11. whenever a returned packet is received (which is once a second, if
  12. everything is working).  So you can go wandering around your network
  13. trying to locate problems, and if you fiddle the right connector and
  14. things suddenly start working again, you'll know about it because
  15. you'll hear this voice in the background going PING ... PING ... PING
  16. (or making whatever other sound you want.)
  17.  
  18.  
  19. Before you run this, you need to find an appropriate sound source, 
  20. and change one line in the script to indicate how you want
  21. the sound produced.  (The default is just to echo a beep,
  22. which works and is portable, but isn't very exciting.)
  23.  
  24. If you're on a NeXT, you can do this:
  25.  
  26.     % sndrecord ping.snd
  27.     hit RETURN 
  28.     say "PING" into the microphone
  29.     hit RETURN again - quickly, you want the sound file 
  30.     to be less than one second long.
  31.  
  32.     edit the script to add this line
  33.  
  34.     makenoise="sndplay ping.snd"
  35.  
  36.  
  37.     [NeXT users may prefer to get the NeXTStep program "Ping.app",
  38.      written by Chris Kane (kane@nic.gac.edu) which is based on
  39.      this idea, only with a graphical interface.   You can
  40.      ftp it from nic.gac.edu, it's pub/next/apps/Ping2.0.tar.Z]
  41.  
  42.  
  43. If you're on a Sparcstation, and you have a microphone attached
  44.     
  45.     % cat /dev/audio >ping.snd
  46.     say "PING" into the microphone
  47.     *QUICKLY* hit control-C (or your interrupt character) to make
  48.     sure the sound file is less than 1 second long.
  49.  
  50.     edit the script to add this line
  51.  
  52.     makenoise="cat ping.snd >/dev/audio"
  53.  
  54.  
  55. Of course you may be able to find (or prepare) a better sound file, such as
  56. a nice submarine "PINGGGGG" sound effect, somewhere else.  Just substitute
  57. the appropriate definition of "makenoise" into this script.
  58.  
  59. Here's the script.  Don't forget to change the definition of "makenoise"
  60. if you want something other than a control-G beep.
  61.  
  62.  
  63. #!/bin/sh
  64. # audioping host
  65. # Ping a host, make a noise for each packet received.
  66. # Useful for network debugging.
  67. # Works on Sparcstations and Nexts.
  68. #
  69. # Be sure to uncomment the appropriate 'makenoise' line, depending
  70. # on whether you want a simple ^G beep or a more complex sound.
  71. #
  72. # Steve Hayman
  73. # Indiana University
  74. # sahayman@cs.indiana.edu
  75. # Tue Feb 19 16:06:00 EST 1991
  76.  
  77. PATH=/etc:/usr/etc:/bin:/usr/bin:/usr/ucb export PATH
  78.  
  79. case "$#" in
  80. 1)     ;;
  81. *)    echo "$0: Use: $0 hostname" 1>&2; exit 1 ;;
  82. esac
  83.  
  84. # Set the 'makenoise' variable to some sort of program
  85. # that makes a noise.  This can be whatever you want,
  86. # but if the noise is more than 1 second long you'll have problems
  87. # with timing getting out of sync.
  88.  
  89.  
  90. # On a plain ordinary terminal, make a noise by echoing a control-G.
  91. # (We do it this way so that we don't have to put a literal ^G in this file.)
  92. makenoise='echo -n . | tr . \\07'
  93.  
  94. # On a Sun, if you have an appropriate sound file, you can make
  95. # a noise this way:
  96. # makenoise="cat /some/sound/file >/dev/audio"
  97.  
  98.  
  99. # On a NeXT you can play a sound file this way.
  100. # Try running "snrdrecord some-file.snd", hit RETURN,
  101. # say "PING" into the microphone, hit RETURN again.
  102. #
  103. # makenoise="sndplay some-file.snd"
  104.  
  105. ping -r -s $1 | tee /dev/tty | while read line; do
  106.     case "$line" in
  107.     *icmp*)    eval $makenoise ;;
  108.     esac
  109.  
  110. done
  111.