delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/21/15:51:31

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Hannu E K Nevalainen" <garbage_collector AT telia DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: how to get IP with a shell command?
Date: Wed, 21 Apr 2004 21:49:40 +0200
Message-ID: <NGBBLLIAMFLGJEOAJCCEAEFEDKAA.garbage_collector@telia.com>
MIME-Version: 1.0
In-Reply-To: <20040421182347.870B3335B6@mailk.telia.com>

> From: Abe Backus
> Sent: Wednesday, April 21, 2004 8:23 PM

> I rely more on where I'm logging into when automating my DISPLAY
> variable... I assume that the parsed output of ipconfig might be
> incorrect in some instances (for instance when I VPN to work and
> ipconfig display more than one IP).  The output of "who am I" on the
> box you log into usually gives a good address.
>
> I put various if/else statements in my .bashrc and .cshrc on the
> boxes that I log into that end up invoking this:
>
> export DISPLAY=`who am i | sed -e 's/.*(\(.*\)).*/\1/'`:0.0
>
> -Abe
>
> -----Original Message-----
>
> To set the environment variable DISPLAY for XFree I use the following
> command
>
> export DISPLAY=`\
>     ipconfig | grep 'IP-Adresse' | \
>     sed 's/\(.*:
> \)\([0-9][0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)\(.*\)/\2/g'`:0.0
>
> 'IP-Adresse' must be replaced with the proper version according to you
> language.

Well, "who am i" is just a synonym for "id -un" (as stated by "who --help")
on cygwin; here it only prints the current user name;

$ who am i
Hannu    tty0         Apr 21 20:47 (:0)
$ who
Hannu    tty0         Apr 21 20:47 (:0)
$ whoami
Hannu

The ipconfig stuff isn't much more reliable, depending on your setup.
I always have TWO IP's when my PPP/ISDN is up:

$ ipconfig /all

Windows 2000 IP Configuration

        Host Name . . . . . . . . . . . . : P450
        Primary DNS Suffix  . . . . . . . :
        Node Type . . . . . . . . . . . . : Broadcast
        IP Routing Enabled. . . . . . . . : Yes
        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : Intel 21143 Based PCI Fast
Ethernet Adapter #2
        Physical Address. . . . . . . . . : XX-XX-XX-XX-XX-XX
        DHCP Enabled. . . . . . . . . . . : No
        IP Address. . . . . . . . . . . . : 192.168.0.1
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . :
        DNS Servers . . . . . . . . . . . : 195.67.199.18
                                            195.67.199.19
                                            195.67.199.20

PPP adapter Tv? Kanaler, Internjet:

        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface
        Physical Address. . . . . . . . . : 00-53-45-00-00-00
        DHCP Enabled. . . . . . . . . . . : No
        IP Address. . . . . . . . . . . . : 217.208.205.54
        Subnet Mask . . . . . . . . . . . : 255.255.255.255
        Default Gateway . . . . . . . . . : 217.208.205.54
        DNS Servers . . . . . . . . . . . : 195.67.199.15
                                            195.67.199.16
        NetBIOS over Tcpip. . . . . . . . : Disabled


/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E

** on a mailing list; please keep replies on that particular list **

-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019