Hello Everyone,
I want to know how can we make the variables of one script available for the other script?
for example i have three scripts variable_availability.sh,first.sh,second.sh and a file containing variables called common
----------------------------------
cat variable_availability.sh
#!/usr/local/bin/ksh
echo "starting the 1st script"
/root/Shell_Scripts/first.sh
echo "1st script finished"
echo "starting 2nd script"
/root/Shell_Scripts/second.sh
echo "2nd script finished"
--------------------------------
cat first.sh
#!/usr/local/bin/ksh
. /root/Shell_Scripts/common
echo "The value of a=$a before modification"
a=`expr $a - 2`
echo "The value of a=$a after modification in 1st script"
echo "The value of b=$b before modification"
b=`expr $b + 2`
echo "The value of b=$b after modification in 1st script"
---------------------------------
cat second.sh
#!/usr/local/bin/ksh
. /root/Shell_Scripts/common
echo "The value of a=$a in second script"
echo "the value of b=$b in second script"
----------------------------------------------
cat common
#!/usr/local/bin/ksh
a=10
b=20
--------------------------------------------
The output while running the variable_availability.sh script is as follows,
--------------------------------------------
starting the 1st script
The value of a=10 before modification
The value of a=8 after modification in 1st script
The value of b=20 before modification
The value of b=22 after modification in 1st script
1st script finished
starting 2nd script
The value of a=10 in second script
the value of b=20 in second script
2nd script finished
----------------------------------------------
The modified variables 'a' and 'b' in first.sh is not available for second.sh
Please share with me if anybody has any idea on this one.
Thanks in advance..........