From: laredotornado on
Hi,

I'm using Mac 10.6.3, bash shell. How can I get my IP address, as it
would appear in a web server log of a remote server (assuming no
proxies in between)? I would like to get this IP address and put it
in a file on my system.

Thanks, for your help, - Dave
From: pk on
On Mon, 12 Jul 2010 11:44:10 -0700 (PDT) laredotornado
<laredotornado(a)zipmail.com> wrote:

> I'm using Mac 10.6.3, bash shell. How can I get my IP address, as it
> would appear in a web server log of a remote server (assuming no
> proxies in between)? I would like to get this IP address and put it
> in a file on my system.

ifconfig ?

From: Kenny McCormack on
In article <89f693a6-8a8e-4131-aa7d-6d4c933ec8e0(a)k8g2000prh.googlegroups.com>,
laredotornado <laredotornado(a)zipmail.com> wrote:
>Hi,
>
>I'm using Mac 10.6.3, bash shell. How can I get my IP address, as it
>would appear in a web server log of a remote server (assuming no
>proxies in between)? I would like to get this IP address and put it
>in a file on my system.
>
>Thanks, for your help, - Dave

The obvious answer is: Parse the output of ifconfig (post back if you
need more detailed instructions).

The longer answer is: People are usually using some kind of NAT, so the
real question is "How do I get my 'real world visible' IP address?".

If it is the later question, there are various solutions, none of them
"perfect" (in the sense of being absolutely deterministic - answerable
in a standard-compliant manner). Again, post back if you want my
suggestions.

--
"We should always be disposed to believe that which appears to us to be
white is really black, if the hierarchy of the church so decides."

- Saint Ignatius Loyola (1491-1556) Founder of the Jesuit Order -

From: Chris F.A. Johnson on
On 2010-07-12, laredotornado wrote:
> Hi,
>
> I'm using Mac 10.6.3, bash shell. How can I get my IP address, as it
> would appear in a web server log of a remote server (assuming no
> proxies in between)? I would like to get this IP address and put it
> in a file on my system.

ipaddr=$(wget -qO - http://cfaj.freeshell.org/ipaddr.cgi)

--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)

From: laredotornado on
On Jul 12, 2:13 pm, "Chris F.A. Johnson" <cfajohn...(a)gmail.com> wrote:
> On 2010-07-12, laredotornado wrote:
> > Hi,
>
> > I'm using Mac 10.6.3, bash shell.  How can I get my IP address, as it
> > would appear in a web server log of a remote server (assuming no
> > proxies in between)?  I would like to get this IP address and put it
> > in a file on my system.
>
> ipaddr=$(wget -qO -http://cfaj.freeshell.org/ipaddr.cgi)
>
> --
>    Chris F.A. Johnson, author           <http://shell.cfajohnson.com/>
>    ===================================================================
>    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
>    Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)

Thanks for this excellent, concise solution. That was indeed the
simple answer I was looking for, - Dave