setting env vars

Net Llama! netllama
Mon May 17 11:44:16 PDT 2004


On Mon, 10 Feb 2003, David A. Bandel wrote:
> On Mon, 10 Feb 2003 11:40:25 -0500 (EST)
> Net Llama! <netllama at linux-sxs.org> wrote:
>
> > I've got a two pronged question regarding environmental variables
> > (under bash):
> >
> > 1) Is it possible to use env vars for things like IP addresses &
> > hostnames in files in /etc/hostname & /etc/hosts?
> > 2) If so, where would be the best place to set them, so that they are
> > identified at bootup?
>
> One of us is extremely confused.
>
> Environment variables are meant for users and/or programs.  They create
> and/or modify interactions between userland programs (including the
> shell) launched by a user (or possibly by the system on behalf of the
> user) and the system itself. That is, they modify how/what the
> user/program "sees" while executing a program or command. The system
> doesn't have any environment variables because it doesn't need them.
> And /etc/hostname, et. al., are not executable programs to be run or
> interpreted by anyone, they are system references.
>
> What are you trying to do?  Because either you're trying to use
> something for a purpose it wasn't designed for, or you're using the
> wrong terms for the question.
>
> To answer your question, though, it is possible during boot to modify
> the contents of system reference files (/etc/hosts, /etc/resolv.conf,
> etc.).  DHCPCD changes /etc/resolv.conf for one.

What i'm trying to do is put something like this in (for example)
/etc/hosts:
$IPADDR		$HOSTNAME

and then set $IPADDR=192.168.0.3 and $HOSTNAME=foo.bar.com

is this possible?

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lonni J Friedman				netllama at linux-sxs.org
Linux Step-by-step & TyGeMo		     http://netllama.ipfox.com


More information about the Linux-users mailing list