LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 12: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, 01:00 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 01: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



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 08:43 PM
Local vs Global variables wujee Programming 1 03-11-2005 11:43 PM
global variables in php champ Programming 2 10-13-2002 01:31 PM
exporting global variables neo77777 Programming 6 09-18-2002 01:46 PM
global environmental variables antadam Linux - General 2 10-11-2001 06:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:55 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