[ale] Get host's IP address as an unprivileged user?

Michael Trausch mike at trausch.us
Sat Jun 4 14:24:20 EDT 2011


$ ip ls

You can grep for the if you're interested in. ip, from the iproute2 package,
is the preferred mechanism for working with the networking stack in Linux;
it is far more capable than ifconfig is.

--
Sent from my phone... a G2 running CM7 nightlies!
On Jun 4, 2011 1:51 AM, "James Sumners" <james.sumners at gmail.com> wrote:
> I need to get the IP address of the local machine on which a script is
> being executed. The script is going to be run by an unprivileged user
> (so /sbin is not in the PATH). Does anyone know of a better way than
> this:
>
> IP=$(host $(hostname) | awk '{print $4}')
>
> --
> James Sumners
> http://james.roomfullofmirrors.com/
>
> "All governments suffer a recurring problem: Power attracts
> pathological personalities. It is not that power corrupts but that it
> is magnetic to the corruptible. Such people have a tendency to become
> drunk on violence, a condition to which they are quickly addicted."
>
> Missionaria Protectiva, Text QIV (decto)
> CH:D 59
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20110604/3a3c3a9b/attachment.html 


More information about the Ale mailing list