[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: How to modify evironment variables in a C program



Just print the string to stdout.  The REXX script should be able to read
that directly, rather than the temp file.

That's what Alan was suggesting with 'eval'.  I don't know REXX, so I'll
give you a bash example.  If your C application needed to set a variable
called "IFNAME" in the parent bash script, it could printf the value
before it exits, like so:
	printf( "IFNAME=\"%s\"", ifname_value );
It could even printf more than one such statement.  The format of that
statement is a bash variable assignment.  If the bash script were to
call that C program like this:
	eval `my-print-ifname`
The bash script would execute the program, read the output, and execute
those commands itself.  As a result, the variables that the C program
wrote to stdout are interpreted and assigned in the bash process.

On Mon, 2002-03-11 at 09:49, Xanh wrote:
> Thank you for all the replies.  Now I understand why.
> Here is my problem.  I have a script (written in REXX, a interpreted
> scripting language) that need to read a string created by a C program.
> Currently, I use a temporary file.  The C code writes the string to a file
> and then latter the script will read it.  I hope to simplify things by using
> an environment variable, but it does not seem to be working.   What would
> you do to solve this problem?
> 
> Regards,
> Nemo
> 
> 
> ----- Original Message -----
> From: "Alan Peery" <peery io com>
> To: <redhat-list redhat com>
> Sent: Saturday, March 09, 2002 3:12 AM
> Subject: Re: How to modify evironment variables in a C program
> 
> >
> > As designed.  If any child program could alter the values of the
> environment
> > setting in their parent process, chaos could ensue.  Imagine for a moment
> that
> > I convince you to play my game called "rogue"--and then change your
> session so
> > that your path is altered to find different commands.
> >
> > Try "man sh", then search for "eval" within the man page.
> >
> > Alan
> >
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> 
> _______________________________________________
> Redhat-list mailing list
> Redhat-list redhat com
> https://listman.redhat.com/mailman/listinfo/redhat-list






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]