help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

basic network detect


From: BRUCE INGALLS
Subject: basic network detect
Date: Mon, 16 Jan 2006 18:38:01 -0500

I wrote some code, but tested it on only one system. I wish to add it
to the next version of my GPL http://emacro.sf.net/ project.
The purpose is to, as feasibly as I can, test if the user has
 o  broadband
 o  dialup
 o  no network

Please run the following code on your unix/osx-like system. If it
fails, please email me directly the output of ifconfig (you can trim
out the actual numbers, such as IP address), or fill in your relevant
/dev device name.
Let me know, if ifconfig itself fails.

;;;cut here

(let ((ifconfig (shell-command-to-string "ifconfig")) ;posix: linux/osx/unix
      (ipconfig (shell-command-to-string "ipconfig"))) ;w32

      (cond
       ((string-match "Media disconnected" ipconfig)
        (message "w32 modem or no network"))

       ((string-match "IP Address" ipconfig)
        (message "w32 broadband, or currently (perhaps always?) connected"))

       ((string-match "eth[0-9]" ifconfig)
        (message "Linux ethernet"))

       ((string-match "tty" ifconfig)
        (message "Linux/Unix modem"))

       ((string-match "e[0-9]" ifconfig)
        (message "Solaris ethernet"))

       ((string-match "rl[0-9]" ifconfig)
        (message "BSD ethernet"))

       ((string-match "vr[0-9]" ifconfig)
        (message "BSD ethernet"))

       ((string-match "tr[0-9]" ifconfig)
        (message "Linux/Unix token ring"))

       ('t message "Default: nothing found = modem or no network")))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]