Postby **mudasir** » Thu Oct 29, 2009 8:37 am

Assalam-o-alaikum,

Thanks allot for the help, i have completed the user input validation function. Now i am stuck in another mathematical error. Please help me out in this.

my script takes 6 parameters as input

./<script name> X1 Y1 Z1 X2 Y2 Z3

then script perform some calculation on these values, where i am stuck is that, if Y1 value or any other value has a "-" sign with it, shell gives me an error

DIV=`expr $Y2 - $Y1`

T=`expr -$Y1 / $DIV` &> /dev/null

this is where i get an error, error is

"expr: non-numeric argument"

when script run in debug mode i see

++ expr 2 - -2

+ DIV=4

++ expr --2 / 4

the double "--" sign is creating problem.

The formula through which i have to do calculation has a "-" sign so how to overcome this issue.

Thanks in advance.