TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JAMIE KOWINSKY
from: BOB STOUT
date: 1998-02-02 05:11:00
subject: Enviorment variables

On , Jamie Kowinsky (1:129/230@fidonet) wrote: 
 > Can anyone post some sample code on how to read enviorent vars from
 > the current enviorment, and if possible how to modify them?
 > The system I am working with is HP-UX 10.20 but would also like the
 > code to work with a Linux system.
Jamie...
  The only standard way to read them is using the standard getenv() function, 
which I know HP-UX supports.
  There is no standard way to set an environment variable, although there are 
several more-or-less portable, albeit non-standard extensions. The most 
common is to allow passing an environment block when using an exec call (also 
the spawn family of functions for our DOS/Win readers). Also, many compilers 
support the use of a complementary putenv() function, which has the advantage 
of being usable with the standard system() function.
  Note, however, that whatever method you use to change an environment 
variable, it will only be changed for the duration of the current process. 
This is a commmon limitation not only of Unix, but also of all PC OS's as 
well. It's also a FAQ. There's one answer why in Steve Summit's FAQ list, 
plus another in the SNIPPETS file, ENVIRON.TXT. 
--- QM v1.00
---------------
* Origin: MicroFirm : Down to the C in chips (1:106/2000.6)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.