LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   exporting variables (https://www.linuxquestions.org/questions/programming-9/exporting-variables-376379/)

gecoool 10-24-2005 09:55 AM

exporting variables
 
hello

I need to export from an app an environment variable, so a script could see it's value. Actually i need to comunicate a scalar value from the app to the script (i.e. app is processing some tables from a database, and i need to know from the script, which table is being processed). I tried something like:

putenv((char *)(nr_tbl_s.str()).c_str());
system("export tbl");

but it didn't work ...

please help

MensaWater 10-24-2005 10:04 AM

The shells (bash and ksh at least) do "export VAR=VALUE" so it appears your "system(export tbl)" is wrong - it would need to be "system(export tbl=VALUE)" assuming you want the shell to see a variable named "tbl" (as opposed to "tbl" being a variable within C). Unfortunately I don't know enough about C to tell you how to get C variable as the shell variable but did want to make a note on the proper usage of the shell "export" facility you're calling.

gecoool 10-25-2005 01:17 AM

thanks, jlightner !


All times are GMT -5. The time now is 03:59 AM.