From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2790 invoked from network); 14 Jun 2004 12:26:33 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 14 Jun 2004 12:26:33 -0000 Received: (qmail 9499 invoked from network); 14 Jun 2004 12:25:54 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Jun 2004 12:25:54 -0000 Received: (qmail 6162 invoked by alias); 14 Jun 2004 12:25:33 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7544 Received: (qmail 5297 invoked from network); 14 Jun 2004 12:23:53 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 14 Jun 2004 12:23:50 -0000 Received: (qmail 7873 invoked from network); 14 Jun 2004 12:23:50 -0000 Received: from asclepius3.uwa.edu.au (HELO asclepius.uwa.edu.au) (130.95.128.60) by a.mx.sunsite.dk with SMTP; 14 Jun 2004 12:23:46 -0000 Received: from asclepius (localhost [127.0.0.1]) by asclepius (Postfix) with SMTP id 2A83C369F58 for ; Mon, 14 Jun 2004 20:23:43 +0800 (WST) Received: from gulag.gu.uwa.edu.au (gulag.guild.uwa.edu.au [130.95.100.5]) by asclepius.uwa.edu.au (Postfix) with ESMTP id 4B16036C99C for ; Mon, 14 Jun 2004 20:23:33 +0800 (WST) Received: from gulag.guild.uwa.edu.au (devenish@localhost [127.0.0.1]) by gulag.gu.uwa.edu.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id i5ECNPFt022343 for ; Mon, 14 Jun 2004 20:23:25 +0800 Received: (from devenish@localhost) by gulag.guild.uwa.edu.au (8.12.3/8.12.3/Debian-6.6) id i5ECNOtL022341 for zsh-users@sunsite.dk; Mon, 14 Jun 2004 20:23:24 +0800 Date: Mon, 14 Jun 2004 20:23:24 +0800 From: James Devenish To: zsh-users@sunsite.dk Subject: Re: how do I find my IP address Message-ID: <20040614122324.GA21872@mail.guild.uwa.edu.au> Mail-Followup-To: zsh-users@sunsite.dk References: <67BDB808-BDA2-11D8-9044-000A957D73C4@chemistry.ucsc.edu> <20040613233708.A28043@redfish.gatech.edu> <20040614115736.GJ19941@ay.vinc17.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040614115736.GJ19941@ay.vinc17.org> User-Agent: Mutt/1.3.28i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 In message <20040614115736.GJ19941@ay.vinc17.org> on Mon, Jun 14, 2004 at 01:57:36PM +0200, Vincent Lefevre wrote: > On 2004-06-13 23:37:08 -0400, Jason Price wrote: > > On most unix flavors, some varient of: > > ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{print $2}' > > should work. > Not under linux. This is still OS-dependent. With ifconfig, you > probably need to filter on \d+\.\d+\.\d+\.\d+ in particular. > BTW, can zsh do such things internally (without using external > programs like sed or perl)? Well, for string manipulation, you can use zsh expressions (e.g. loops, pattern matching and string manipulation) rather than relying on sed or awk, if that is what you're asking. If you're asking whether zsh can "find out your IP address", that's a bigger problem, with no "correct" answer in the general case. For a start, do you want your host's IPv4 address or its IPv6 address? And for which interface (loopback, PPP, Ethernet, or secure tunnel)? And what if you have multiple Ethernet interfaces, or if you have multiple subnets and aliases (e.g. your machine has a "private" address as well as public address)? And so on. Although each machine has a "hostname", there are potentially many addresses that represent that host. I suppose there might be some "standard" resolver library routines that could return just a single IP address, and this would work for "most people". But, even so, my guess is that this sort of network information might still be best left as part of an optional zsh module if at all. Don't forget that zsh has a 'periodic' function that could be used to retest a host's IP address every 5 mins, for instance, as an alternative to invoking `ifconfig` every time the prompt is generated.