Hello,
How do I export a change to an environment variable made in a C program?
I tried setenv() and putenv(), but the change is not visible to the shell.

////////// testenv.c
int main(int argc, char* argv[], char* envp[])
{
        char* p;
        p = getenv("MyTest");
        printf("current value: %s\n", p);

        setenv("MyTest", "New value here", 1);
        p = getenv("MyTest");
        print("new value: %s\n", p);

        return 0;
}
/////////
I compiled the code and test in a bash shell:

$>export MyTest="Current Value"
$>./testenv
    current value: Current Value
    new value: New value here
$>echo $MyTest
    Current Value

The old value is retained.
Thanks for your help.

Regards,
Nemo Mai





_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to