How to link a variable in muparserX and the shell

75 views Asked by At

I have variables taken from a text file as such:

ml1=1
ml2=2
ml3=3

ad1=1
ad2=2
ad3=3

I want to use these variables in otbcli_BandMath like so:

otbcli_BandMath -il ${MY_INPUT}_B2.TIF -out B2TOA.TIF -exp '(ml2*im1b1)+ad2'

But it keeps showing that ml2 and ad2 are not recognised. This is because they are defined in the bash shell script and i've read that once in the expression quotes otb uses muparserX and so the variables must be defined in muparserX in order to be used. My problem is that i do not know how to use muparserX as i'm very new to programming. Does anyone know how i can use my predefined variables in the expression quotes?

1

There are 1 answers

0
Walshe_d On BEST ANSWER

I used "" instead of '' and also forgot to use $ when calling the variables. It has worked now with this script.

otbcli_BandMath -il ${MY_INPUT}_B2.TIF -out B2TOA.TIF -exp "($ml2*im1b1)+$ad2"