home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / interfaces / ping.el < prev    next >
Encoding:
Text File  |  1990-07-22  |  1.9 KB  |  58 lines

  1. ;From ark1!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!uwm.edu!cs.utexas.edu!mailrus!accuvax.nwu.edu!krulwich Sat May 12 23:40:50 EDT 1990
  2. ;Article 1917 of comp.emacs:
  3. ;Path: ark1!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!uwm.edu!cs.utexas.edu!mailrus!accuvax.nwu.edu!krulwich
  4. ;From: krulwich@ils.nwu.edu (Bruce Krulwich)
  5. ;Newsgroups: comp.emacs
  6. ;Subject: PINGing other machines
  7. ;Message-ID: <7477@accuvax.nwu.edu>
  8. ;Date: 9 May 90 17:26:32 GMT
  9. ;Sender: news@accuvax.nwu.edu
  10. ;Reply-To: krulwich@ils.nwu.edu (Bruce Krulwich)
  11. ;Organization: Institute for the Learning Sciences, Northwestern University, Evanston, IL 60201
  12. ;Lines: 42
  13. ;
  14. ;The GNU emacs-lisp code below can be used to check if another machine is up
  15. ;and if the network connection to it is up.  It does this by spawning a
  16. ;background job and notifying you as soon as it gets an answer.  I've found
  17. ;it useful in an environment where the network is sometimes flakey and
  18. ;machines that I have to connect to sometimes go down.
  19. ;
  20. ;Send any comments and/or suggestions to krulwich@ils.nwu.edu.
  21.  
  22.  
  23. ;;;  --------------------------------------------------------------------------
  24.  
  25. ;;;  PING -- Do a background ping of another machine
  26. ;;;  Bruce Krulwich
  27. ;;;  Institute for the Learning Sciences
  28. ;;;  3/4/90
  29.  
  30. (defun ping (host)
  31.   (interactive "sHost to ping (in background): ")
  32.   (if (get-process "ping")
  33.       (error "Previous ping hasn't finished yet")
  34.       (let ((proc
  35.          (start-process "ping" nil "ping" host) ))
  36.     (set-process-filter proc 'ping-filter)
  37.     (set-process-sentinel proc 'ignore)
  38.     )))
  39.  
  40. ;;; The INSERT is instead of MESSAGE so that user keystrokes won't erase it
  41. ;;; as soon as it's displayed.
  42. (defun ping-filter (proc msg)
  43.   (save-excursion
  44.     (set-buffer (window-buffer (minibuffer-window)))
  45.     (insert (substring msg 0 (1- (length msg))))
  46.     ))
  47.  
  48. ;;;  --------------------------------------------------------------------------
  49.  
  50.  
  51. ;Enjoy,
  52. ;
  53. ;Bruce
  54.  
  55.  
  56.  
  57.  
  58.