[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Get host's IP address as an unprivileged user?
- Subject: [ale] Get host's IP address as an unprivileged user?
- From: jdp at algoloma.com (JD)
- Date: Sat, 04 Jun 2011 07:28:38 -0400
- In-reply-to: <[email protected]>
- References: <[email protected]>
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).