Hi all,
I am trying to set up some variables in a shell script. The variables contain values of various paths needed to run a java module. The problem is the variables dont seem to be setting at all.
This echo prints the value correctly. Where as if i do the same from unix prompt after executing the script, the variable is always empty. I have tried all kinds of things here(including export CLASS_PATH=value and export SET CLASS_PATH=value among others) and am not able to figure the problem.
I have a similar problem, however I want to manage all variables in a single file and as such run this file at the beginning of all scripts requiring that environment variables.
scripts1 is as follows :-
ABC="ABC"
xyz="xyz"
export EXP="EXPORT"
script2 is as follows :-
./sc1
echo $ABC
echo $xyz
echo $EXP
Apologies, I misread your message. It works great, however the variables remain constant. I have a variable for date and time which I need it to be set at execution time of the line using the var. What I have is as follows :-
In script1 I define the var
DT=`date +"%d-%h-%y|%H:%M:%S"`
In script2 I use the var
echo ${DT}
sleep 2
echo ${DT}
In this case move the DT variable assignment to script two; and set your values before and after the sleep to get different values of the DT variable. You script is working the way you have coded it to work.