zsh-users
 help / color / mirror / code / Atom feed
From: James Devenish <j-devenish@users.sourceforge.net>
To: zsh-users@sunsite.dk
Subject: Re: how do I find my IP address
Date: Mon, 14 Jun 2004 20:23:24 +0800	[thread overview]
Message-ID: <20040614122324.GA21872@mail.guild.uwa.edu.au> (raw)
In-Reply-To: <20040614115736.GJ19941@ay.vinc17.org>

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.



  reply	other threads:[~2004-06-14 12:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-14  1:30 William Scott
2004-06-14  3:37 ` Jason Price
2004-06-14 10:58   ` Jussi Pakkanen
2004-06-14 11:57   ` Vincent Lefevre
2004-06-14 12:23     ` James Devenish [this message]
2004-06-14 13:18       ` Vincent Lefevre
2004-06-14  3:57 ` Timothy Luoma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040614122324.GA21872@mail.guild.uwa.edu.au \
    --to=j-devenish@users.sourceforge.net \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).