LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-19-2009, 01:14 AM   #1
Swapna173
LQ Newbie
 
Registered: Dec 2007
Posts: 25

Rep: Reputation: 15
global variables


Hi,

I hav created a script that calls a sub-script. In both the scripts i called the configuration file. Now i wanted to use a variable that should be used in both script and sub-script files. Actually, i wanted to return a file name and the return status to the script file from the sub-script.

I hav used export in both script n sub-script but its' not working

How can i solve the same
 
Old 03-19-2009, 02:00 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
You can only export bash vars downwards ie to a sub-proc, not back up to parent.
You can;

1. use a fn instead
2. have a list/arr of expected rtns and use the rtn code to match
3. use a temp file
4. have the sub-proc rtn string on stdout and catch that eg
rslt=`sub_proc ...`



tldp.org/LDP/abs/html/
 
Old 03-19-2009, 02:01 AM   #3
emailbuilder88
LQ Newbie
 
Registered: May 2005
Posts: 23

Rep: Reputation: 1
You should show snippets of the scripts, preferably without unrelated code - just try to get a simple example working first. Aside from exporting variables, you can try more advanced IPC (google it) procedures or another hackish solution would be for one script to write the needed value(s) to a file that the other one reads.

Really, you need to show more details and specify what language you are using.
 
  


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
g++ complains about global variables copolii Programming 3 09-18-2005 09:43 PM
Local vs Global variables wujee Programming 1 03-12-2005 12:43 AM
global variables in php champ Programming 2 10-13-2002 02:31 PM
exporting global variables neo77777 Programming 6 09-18-2002 02:46 PM
global environmental variables antadam Linux - General 2 10-11-2001 07:36 AM


All times are GMT -5. The time now is 01:03 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration