Results 1 to 2 of 2
I have the following function, and it appears to set the var correctly, but then tries and executes the line as a command. Anyone know how to keep it from ...
- 05-07-2010 #1
[SOLVED] Setting var returns command not found
I have the following function, and it appears to set the var correctly, but then tries and executes the line as a command. Anyone know how to keep it from doing that?
Please don't modify the code, other than the "RIGHT HERE" code. I need it this way, but I am only giving a partial story with the code.PHP Code:SMALL_FILE_PERCENTAGE=88
MEDIUM_FILE_PERCENTAGE=10
LARGE_FILE_PERCENTAGE=2
DATA_TOTAL=1500
DATA_TYPE=MB
myfunction (){
PERCENTAGE=$((${1}_FILE_PERCENTAGE))
DTYPE=$TOTAL_DATA_TYPE
echo ==== PERCENTAGE ==== $PERCENTAGE #This works correctly
if [[ "$DTYPE" == "KB" ]]; then
echo test kb
elif [[ "$DTYPE" == "MB" ]]; then
[B] ${i}_TOTAL=123 <-------RIGHT HERE[/B]
elif [[ "$DTYPE" == "GB" ]]; then
echo test gb
elif [[ "$DTYPE" == "TB" ]]; then
echo test tb
fi
}
for i in SMALL MEDIUM LARGE
do
myfunction $i
done
Essentially, it will set a SMALL_TOTAL=12345, MEDIUM_TOTAL=blah, blah, blah. I am going to take the total and convert it into bytes based on the DATA_TYPE
Thanks in advance
- 05-07-2010 #2


Reply With Quote