Results 1 to 3 of 3
Hi ,
One of my file t1.sh has got some variables with values set.
When I run the second script I can not get the values of variables set in ...
- 07-28-2011 #1Just Joined!
- Join Date
- Dec 2010
- Posts
- 14
values of variables lost between two shell scripts
Hi ,
One of my file t1.sh has got some variables with values set.
When I run the second script I can not get the values of variables set in 1st script. Though I can only echo SYS Level set variables.
Any idea?
Many thanks
- 07-28-2011 #2
Completely normal.
Variables are only valid within one process.
One method is to call the second script with parameters, and then parse the parameters into variables within the second script.You must always face the curtain with a bow.
- 07-29-2011 #3Just Joined!
- Join Date
- Jun 2011
- Posts
- 30
This is possible, but you must export the variables and execute t1.sh in the same process as your script:
Code:$> cat t1.sh #!/bin/bash export FOO="bar" BAR="foo" $> cat script.sh #!/bin/bash echo "var FOO equals: <$FOO>" echo "var BAR equals: <$BAR>" $> . ./t1.sh $> $> ./script.sh var FOO equals: <bar> var BAR equals:<> $>. ./script.sh var FOO equals: <bar> var BAR equals: <foo>


Reply With Quote