Loading ...
Sorry, an error occurred while loading the content.

How to detect if my PC is networked within _vimrc?

Expand Messages
  • Xiangjiang Ma
    Hi, I am trying to build a little intelligent map: if(my_pc_is_connected) map ... else map ... endif But, how to do detection? Thanks -- Xiangjiang Ma
    Message 1 of 3 , Dec 1, 2002
    • 0 Attachment
      Hi,

      I am trying to build a little intelligent map:

      if(my_pc_is_connected)
      map ...
      else
      map ...
      endif

      But, how to do detection?

      Thanks





      --
      Xiangjiang Ma


      _________________________________________________________________
      The new MSN 8: advanced junk mail protection and 2 months FREE*
      http://join.msn.com/?page=features/junkmail
    • Piet Delport
      ... You ll probably need to call some external command, appropriate for the OS you re on. On Unix, you can do something like: if (system( ifconfig ) =~
      Message 2 of 3 , Dec 1, 2002
      • 0 Attachment
        On Sun, 01 Dec 2002 at 14:57:36 -0800, Xiangjiang Ma wrote:
        >
        > I am trying to build a little intelligent map:
        >
        > if(my_pc_is_connected)
        > map ...
        > else
        > map ...
        > endif
        >
        > But, how to do detection?

        You'll probably need to call some external command, appropriate for the
        OS you're on. On Unix, you can do something like:

        if (system('ifconfig') =~ '^tun0:.\{-}\<UP\>')

        (substituting `tun0' for the interface you're interested in, of course)

        In Windows, it's a bit harder. I don't know how to go about it on
        Windows 9x, but on NT and derivatives, it might be possible to get the
        interface's state by looking at the output of the `ipconfig' command.

        --
        Piet Delport
        Today's subliminal thought is:
      • Antoine J. Mechelynck
        ipconfig exists in Win98 too. See below is what I get (in French) Tony. C: WINDOWS ipconfig Configuration IP de Windows 98 0 - Carte Ethernet : Adresse IP. .
        Message 3 of 3 , Dec 1, 2002
        • 0 Attachment
          ipconfig exists in Win98 too. See below is what I get (in French)

          Tony.

          C:\WINDOWS>ipconfig

          Configuration IP de Windows 98

          0 - Carte Ethernet :

          Adresse IP. . . . . . . . . : 217.136.65.181
          Masque de sous-réseau . . . : 255.255.255.0
          Passerelle par défaut . . . : 217.136.65.181

          1 - Carte Ethernet :

          Adresse IP. . . . . . . . . : 0.0.0.0
          Masque de sous-réseau . . . : 0.0.0.0
          Passerelle par défaut . . . :

          C:\WINDOWS>ipconfig /all

          Configuration IP de Windows 98

          Nom d'hôte . . . . . . . . : TONYMEC
          Serveur DNS. . . . . . . . : 195.238.2.21
          195.238.2.22
          Type de noeud. . . . . . . : Diffuser
          ID étendue NetBIOS . . . . :
          Routage IP activé. . . . . : Oui
          Proxy WINS activé. . . . . : Non
          Résolution NetBIOS par DNS : Non

          0 - Carte Ethernet :

          Description . . . . . . . . : PPP Adapter.
          Adresse physique. . . . . . : 44-45-53-54-00-00
          DHCP activé . . . . . . . . : Oui
          Adresse IP. . . . . . . . . : 217.136.65.181
          Masque de sous-réseau . . . : 255.255.255.0
          Passerelle par défaut . . . : 217.136.65.181
          Serveur DHCP. . . . . . . . : 255.255.255.255
          Serveur WINS principal. . . :
          Serveur WINS secondaire . . :
          Bail obtenu . . . . . . . . : 01 01 80 00:00:00
          Bail expirant . . . . . . . : 01 01 80 00:00:00

          1 - Carte Ethernet :

          Description . . . . . . . . : PPP Adapter.
          Adresse physique. . . . . . : 44-45-53-54-00-01
          DHCP activé . . . . . . . . : Oui
          Adresse IP. . . . . . . . . : 0.0.0.0
          Masque de sous-réseau . . . : 0.0.0.0
          Passerelle par défaut . . . :
          Serveur DHCP. . . . . . . . : 255.255.255.255
          Serveur WINS principal. . . :
          Serveur WINS secondaire . . :
          Bail obtenu . . . . . . . . :
          Bail expirant . . . . . . . :

          C:\WINDOWS>ipconfig /h
          Configuration IP de Windows 98
          Options de la ligne de commande :
          /All - Affiche des informations détaillées.
          /Batch [file] - écrit dans le fichier ou ./WINIPCFG.OUT
          /renew_all - Renouvelle toutes les cartes réseau.
          /release_all - Libère toutes les cartes réseau.
          /renew N - Renouvelle la carte réseau N.
          /release N - Libère la carte réseau N.

          ----- Original Message -----
          From: "Piet Delport" <pjd@...>
          To: <vim@...>
          Sent: Monday, December 02, 2002 12:38 AM
          Subject: Re: How to detect if my PC is networked within _vimrc?

          On Sun, 01 Dec 2002 at 14:57:36 -0800, Xiangjiang Ma wrote:
          >
          > I am trying to build a little intelligent map:
          >
          > if(my_pc_is_connected)
          > map ...
          > else
          > map ...
          > endif
          >
          > But, how to do detection?

          You'll probably need to call some external command, appropriate for the
          OS you're on. On Unix, you can do something like:

          if (system('ifconfig') =~ '^tun0:.\{-}\<UP\>')

          (substituting `tun0' for the interface you're interested in, of course)

          In Windows, it's a bit harder. I don't know how to go about it on
          Windows 9x, but on NT and derivatives, it might be possible to get the
          interface's state by looking at the output of the `ipconfig' command.

          --
          Piet Delport
          Today's subliminal thought is:
        Your message has been successfully submitted and would be delivered to recipients shortly.