LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-24-2005, 09:55 AM   #1
gecoool
Member
 
Registered: Feb 2005
Location: Romania
Distribution: Fedora 2
Posts: 38

Rep: Reputation: 15
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
 
Old 10-24-2005, 10:04 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
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.
 
Old 10-25-2005, 01:17 AM   #3
gecoool
Member
 
Registered: Feb 2005
Location: Romania
Distribution: Fedora 2
Posts: 38

Original Poster
Rep: Reputation: 15
thanks, jlightner !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
exporting variables is getting lame... fast CoolAJ86 Linux - Security 3 01-24-2005 01:09 AM
Exporting variables through scripts rammya Programming 1 04-14-2004 10:24 AM
exporting variables under bash isn't working! dtheorem Programming 6 03-11-2004 08:35 AM
exporting variables in Perl nbp Programming 1 11-18-2003 08:35 AM
exporting global variables neo77777 Programming 6 09-18-2002 01:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration