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 08-05-2005, 09:23 AM   #1
loopoo
Member
 
Registered: Aug 2005
Posts: 40

Rep: Reputation: 15
Export variable


Hi everybody!

I am trying to write a script which will launch some others.
But, i want to get a response from the first script that will be executed by the main one, and, after receiving that, launching some other scripts.

Is it possible do pass a variable from the main script to another one, and then pass it back and check its value?

I am using bash on AIX 4.2

Thanks in advance
LooPoo
 
Old 08-05-2005, 03:18 PM   #2
rstewart
Member
 
Registered: Feb 2005
Location: Sunnyvale, CA
Distribution: Ubuntu
Posts: 205

Rep: Reputation: 38
Hi,

Sure you can. Take a look at the following two shell scripts:

in "shell1" (executable bash shell script)
Code:
#! /bin/bash
Var1="1"
Var2="3"
Var3=`shell2 $Var1 $Var2`
echo "Var3: " $Var3
in "shell2" (executable bash shell script)
Code:
#! /bin/bash
Var1=`expr $1 + $2`
echo $Var1
You can see that shell1 sets up a few variables and passes those variables to shell2. shell2 takes those variables as input arguments, sums them and echos the results. shell1 gets the echoed data from shell2 and assigns it to a third variable. shell1 then goes on to echo out the results to the screen.
 
Old 08-07-2005, 06:45 AM   #3
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Quote:
I am using bash on AIX 4.2
Why? You can use ksh!
 
Old 08-08-2005, 01:46 AM   #4
loopoo
Member
 
Registered: Aug 2005
Posts: 40

Original Poster
Rep: Reputation: 15
Thanks a lot!
That worked just fine!
 
Old 08-08-2005, 04:08 AM   #5
loopoo
Member
 
Registered: Aug 2005
Posts: 40

Original Poster
Rep: Reputation: 15
One problem though...

I still have to echo something else in the child script besides this variable that I want to pass back.
And when I do this, I recieve in the main script everything that I've echoed in the child script.

How can I skip this problem?


Thanks,
LooPoo
 
  


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
How to export environment variable from a bash script dimaash Linux - Newbie 20 08-09-2011 07:12 AM
cannot export result from awk into a variable in a bash script Emmanuel_uk Linux - Newbie 4 03-07-2005 01:54 AM
Export Shell Variable not working maxhugen Linux - Newbie 6 01-06-2005 10:12 PM
How to get 'Window' variable from a 'Widget' variable bordel Programming 0 11-19-2003 03:19 AM
BASH variable export Barbarian Programming 2 11-27-2001 08:37 PM

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

All times are GMT -5. The time now is 04:10 AM.

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