Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: how do I find my IP address
- X-seq: zsh-users 7535
- From: Jason Price <jprice@xxxxxxxxxxxxxxxxxxxx>
- To: William Scott <wgscott@xxxxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Subject: Re: how do I find my IP address
- Date: Sun, 13 Jun 2004 23:37:08 -0400
- In-reply-to: <67BDB808-BDA2-11D8-9044-000A957D73C4@xxxxxxxxxxxxxxxxxx>; from wgscott@xxxxxxxxxxxxxxxxxx on Sun, Jun 13, 2004 at 06:30:23PM -0700
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <67BDB808-BDA2-11D8-9044-000A957D73C4@xxxxxxxxxxxxxxxxxx>
On most unix flavors, some varient of:
ifconfig -a | grep inet | grep -v '127.0.0.1' | awk '{print $2}'
should work.  'ifconfig' can live in various places, but usually it
is in /sbin/ifconfig or /usr/sbin/ifconfig (old unixen might have it
in /etc/ifconfig).
The 'grep inet' should give you all the ip addresses, but will also
have things like netmask.  The 'grep -v 127.0.0.1' will cut out the
localhost definition.  The 'awk '{print $2}' should give you just the
IP address, but it might be in a different field (try 3, 4, etc).
I'm sure there's a way to figure out a pure zsh way to do this, but I 
don't know it.  Also, I strongly suggest figuring this out once,
stashing it in a variable ($MY_IP or some such), and just using that 
variable.
If you're under windows, under cygwin, you're on your own, but I'd
start with 'ipconfig /all'.
--Jason
On Sun, Jun 13, 2004 at 06:30:23PM -0700, William Scott wrote:
> Timothy:
> 
> If you are running a computer with an ip address that changes 
> (dynamically allocated), this will work, although it is kind of ugly:
> 
> define an alias such as:
> 
> alias myip="curl -s http://www.showmyip.com/simple/ | awk '{print $1}'  
> "
> 
> 
> 
> I would echo the output of myip into something at login rather than 
> grab it off the internet every time I hit the return key.
> 
> 
> If you have a static ip address, you should only have to figure this 
> out once.   On Mac OS X you can find this in the System Preferences 
> under file sharing or network settings (I am assuming this on the basis 
> of the Micro$oft email stamp at the bottom of your email.)
> 
> This alias and a whole bunch of stuff that is useful for OS X zsh is 
> distributed by Gary Kerbaugh.  I have links to it and a few of my own 
> zsh functions here:  http://tinyurl.com/3373b
> 
> Bill Scott
> 
> 
>   http://www.apple.com/trailers/lions_gate/fahrenheit_911/
> 
> 
Messages sorted by:
Reverse Date,
Date,
Thread,
Author