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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-28-2011 #1
- Join Date
- Dec 2010
values of variables lost between two shell scripts
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.
- 07-28-2011 #2
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 #3
- Join Date
- Jun 2011
This is possible, but you must export the variables and execute t1.sh in the same process as your script:
$> 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>