# cat /home/test
exp1="aaa"
exp2="bbb"
export exp1
export exp2
execute script
# /home/test
#echo $exp1; echo $exp2
<empty>
<empty>
:-( What to do?
How to export variables?
The content of this topic has been archived on 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.
# cat /home/test
exp1="aaa"
exp2="bbb"
export exp1
export exp2
execute script
# /home/test
#echo $exp1; echo $exp2
<empty>
<empty>
:-( What to do?
How to export variables?
That has nothing to do with OpenWrt and everything to do with how Unix shells work.
When you execute /home/test, those statements do not get executed by the current shell. A new shell is started, the variables are exported, and then the shell dies, because the end of the script is reached (and the variables disappear with it.)
If you want to force the script to execute as part of the current shell, you have to "source" the script. You do this as follows:
# . /home/test
(i.e. fullstop<space>/home/test)
Some shells also support the "source" command:
# source /home/test
which does the same thing.
Note: It's best to use the full path to the script, because otherwise the shell will likely look in the path and find /bin/test, for example, instead of your script.
The discussion might have continued from here.