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

James Sumners james.sumners at gmail.com
Sat Jun 4 10:50:48 EDT 2011


I don't want to absolutely reference anything in the script or add
/sbin to the PATH. I was hoping someone knew of an even simpler trick
than the one I devised, really.

On Saturday, June 4, 2011, JD <jdp at algoloma.com> wrote:
> On 06/03/2011 09:25 AM, James Sumners 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}')
>>
>
> I never trust the PATH in scripts.  Anyone can call /sbin/ifconfig.
> If you must, just add :/sbin to your PATH (ew).
> _______________________________________________
> 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
>

-- 
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



More information about the Ale mailing list