No, a process can't modify the environment of its parent (and the parent of a
program is typically a shell). You could have the program output the desired
environment variable contents and do
% YOURENVVAR=`yourprogramname`
- Rob
> -Original Message-
> From:
> davinci-linux-op
You might want to try setenv(). Just type 'man 3 setenv' in a Linux
shell to get the man-page for that function (which is in stdlib).
Sander
-Original Message-
From:
davinci-linux-open-source-bounces+shuijsen=optelecom-nkf@linux.davin
cidsp.com
[mailto:davinci-linux-open-source-boun
Unless one wants to set a persistant value, that can be used after his/hers
process finishes...
Unfortunately functions like setenv(), putenv(), system("export ...") change
only the current environment of the process itself, not the 'global'
environment of the user (let alone the system).
Regard
Hi,
I have tried some experiments along these lines.
#include
#include
int main(int argc, char *argv[])
{
char *rc;
FILE *fp;
char buffer[256];
putenv("FRED=\"Hello World\"");
rc = getenv("FRED");
if(rc)
printf("rc: %s\n", rc);
else
printf("Not found\
file
fprintf(fh, "EVR=\"%s\"\n", getenv("EVR"));
fclose(fh);
}
[/snippet]
Regards,
Sander
-Original Message-
From: Arie de Muijnck [mailto:leon...@ademu.com]
Sent: Thursday, December 18, 2008 10:52 AM
To: Sander Huijsen; davinci-
-linux-open-source@linux.davincidsp.com
> Subject: RE: A way to export from c an environment var
>
> Well yes, Arie, you are right about that. I did find a
> clever/nasty (you be the judge of that) solution for the
> problem. Simply write the environment variable from within
>
o 18-12-2008 13:02
Aan: Sander Huijsen; davinci-linux-open-source@linux.davincidsp.com
Onderwerp: RE: A way to export from c an environment var
This is overly complex. The initial setting of env var EVR at the beginning of
the script does nothing, and the C program is just using the environment t
Sander Huijsen spiffera, venerdì 19 dicembre 2008 circa:
> I guess there's more than one way to solve a problem. :)
>
> The initial setting of EVR was there just to show that you can also use
> the variable in the C program using getenv(). Your solution works fine
> if there's only one env var to s