🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #871

Re: How can you set an environment variable in a program?

#871
From: Jon Freivald
Date: Tue, 25 Aug 1992 22:13
36 lines
1687 bytes
tyrant@Aardvark.Rain.COM (Rex Goode) writes:

> dmh@superb (Daniel Hermans) writes:
> 
> >hi,
> >i am using turbo c v2.0 to generate a temporary file name,
> >place some data in the temporary file and then close the file. the temp
> >file is then to be used on the command line of another program. both
> >programs are called within a batch file something like:
> 
> >@echo off
> 
> >program1
> >program2 < %tempfile%
> 
> >   system("set tempfile=tmpx.$$$");
> 
> >i tried using system(command) as above but the variable is not set when the
> >program exits probably because system starts a new command.com shell each
> >time
> 
> Absolutely right about the new command.com, with its own environment. That
> is what happens when you use system(). Try setenv(),
> 
> setenv("TEMPFILE=TMPX.$$$);

OK, I don't have TC 2.0, but I do have TC++ 1.0 & 2.0 -- no such critter
as "setenv()" and "putenv()" only changes the environment for the
current process -- as soon as you exit, the variable is gone...

Jon

=============================================================================
		   Jon Freivald ( jaflrn!jaf@uunet.UU.NET )
	 Nothing is impossible for the man who doesn't have to do it.
=============================================================================
Technical Details
Message-ID: <7923PB2w164w@jaflrn.UUCP>
Path: arc1-ca.pugleaf.net!sparky!uunet!utoday!jaflrn!jaf
References: <690@aardvark.Rain.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!utoday!jaflrn!jaf
From: Jon Freivald <jaf@jaflrn.UUCP>
Newsgroups: comp.os.msdos.programmer
Subject: Re: How can you set an environment variable in a program?
Keywords: variable, C
Message-ID: <7923PB2w164w@jaflrn.UUCP>
Date: Tue, 25 Aug 92 18:13:29 EDT
References: <690@aardvark.Rain.COM>
Organization: The Wizzard's Cave, East Meadow, NY
Lines: 36