HOSTNAME: environment variable or not?

bob fcsoft-3Emkkp+1Olsmp8TqCH86vg at public.gmane.org
Fri Feb 18 17:36:29 UTC 2005


Thanks.    Goes to show that you can always learn at least one new thing each 
and every day.

bob
PS.
What would be the C program call to pickup set variables? ie. a variable set 
in the shell from which you launched your C program.

On February 18, 2005 11:24 am, you wrote:
> On Fri, 18 Feb 2005, bob wrote:
> > On a Debian system I've been working with HOSTNAME is not an exported
> > environment variable.   ie.
> > 	export | less
> > doesn't show it.   Nor does the C function getenv("HOSTNAME") pick it up.
> > 	echo $HOSTNAME
> > does?
>
> Note that a variable and an *exported* variable are two different things.
> A variable which is set but *not* exported is visible within the shell
> that set it -- and therefore gets substituted when that shell interprets a
> command using $ in an argument -- but is not passed to the commands the
> shell runs, so getenv() in a command won't find it.  And "export" lists
> only exported variables.
>
> Try "set | less".  That's how you list *all* variables, exported or not.
>
>                                                           Henry Spencer
>                                                        henry at spsystems.net
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list