It's possible to define/declare a global/persistent variable in the /etc/profile file like this:
export my_variable=value
I can use this variable in a shell:
echo $my_variable
But can I also define it by using a script? I want that the modification shall be visible for any other running scripts. And the new value shall of course be available in case of reboot.
Could setenv
be the solution? I don't know because this function isn't available in my linux (variant of openwrt).
I tried export my_variable=new_value
in a script. $my_variable gives correctly the new value in the script. But in another script my_variable has the previous value: the persistent variable didn't change!
I tried echo "export my_variable=new_value" >> /etc/profile
. Same result!