RE: A way to export from c an environment var

2008-12-17 Thread Tivy, Robert
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

RE: A way to export from c an environment var

2008-12-17 Thread Sander Huijsen
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

Re: A way to export from c an environment var

2008-12-18 Thread Arie de Muijnck
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

Re: A way to export from c an environment var

2008-12-18 Thread Phil Quiney
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\

RE: A way to export from c an environment var

2008-12-18 Thread Sander Huijsen
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-

RE: A way to export from c an environment var

2008-12-18 Thread Tivy, Robert
-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 >

RE: A way to export from c an environment var

2008-12-19 Thread Sander Huijsen
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

Re: A way to export from c an environment var

2008-12-19 Thread Andrea Gasparini
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