View Single Post
  #2 (permalink)  
Old 06-20-09, 05:12
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
There are many ways but this is just one method. Save the variable values in a file as code so that the file can be included by any other shell and those variable values read. This program saves 2 variables to a file (tmp.dat).
Code:
#!/bin/sh

# init var
VAL_1=123
VAL_2=567

echo VAL_1=$VAL_1 > tmp.dat
echo VAL_2=$VAL_2 >> tmp.dat

exit
This will create a file tmp.dat that looks like this. Be aware you will need quotes if your values contain strings.
Code:
VAL_1=123
VAL_2=567
Any other program could then read those variable values by just including that file:
Code:
#!/bin/sh

. tmp.dat

echo $VAL_1
echo $VAL_2

exit
Reply With Quote