LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-08-2011, 03:07 AM   #1
auma78
LQ Newbie
 
Registered: Jan 2011
Posts: 10

Rep: Reputation: 0
Smile how to make a variable defined outside a script identefied inside it


hi people

i am runing the below script

foo..

if [ "$type" == "ok" ]
then string=ZZZZ:I=$number
elif [ "$type" == "NOK" ]
then string=ZZZZ:MS1=$number
else echo "wrong input"
exit
fi
./sc2.sh > temp
foo..


the code inside sc2.sh needs to read the input from the variable (string) above.
is there any way to make this variable recognized inside the sc2.sh

can anyone help please?
 
Old 02-08-2011, 05:23 AM   #2
goossen
Member
 
Registered: May 2006
Location: Bayern, Germany
Distribution: Many
Posts: 224

Rep: Reputation: 41
You can use export to set an enviroment variable and then read it from the other script.
 
1 members found this post helpful.
Old 02-08-2011, 11:49 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You could code the first script to run /sc2.sh "$string" > temp and access the value of $string in sc2.sh as $1.
 
Old 02-09-2011, 08:09 AM   #4
auma78
LQ Newbie
 
Registered: Jan 2011
Posts: 10

Original Poster
Rep: Reputation: 0
thanks all,
i tested the exprot and it is working fine (although it has some issue with the expect interpertor but it can be sloved).
regariding the other way i will try to test it as well,thanks
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] exporting a variable defined inside a for loop musonio Linux - General 6 11-06-2009 08:10 PM
create a global associative array variable inside a function of a bash script konsolebox Programming 3 07-14-2009 06:08 AM
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 02:40 PM
How to acess Variable defined in perl script inside an awk call sumin Programming 3 04-26-2007 05:19 AM
Variable expansion inside of a bash script! A.S.Q. Linux - Newbie 4 09-29-2006 09:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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