Link to home
Start Free TrialLog in
Avatar of aik_21
aik_21

asked on

ksh script and db2 problem

Hi everyone
i am using ksh scripts and db2. i need to check in my database if a particular user exists,

echo "PLEASE ENTER THE EMPLOYEE NUMBER"
read enumm
echo "PLEASE ENTER THE MANAGER USER ID"
read uid
echo "PLEASE ENTER THE MANAGER PASSWORD"
read pswd
. db2init
QYE=`db2 -x "select count(*) from manUser where EMPLOYEE#=$enumm and USERID='$uid' and PASSWORD='$pswd'"`
echo "$QYE"
if [[ $QYE = 1 ]]
then
echo "existssss"
else
echo "doesn't exist"
fi

the output is
PLEASE ENTER THE EMPLOYEE NUMBER
1
PLEASE ENTER THE MANAGER USER ID
Admin
PLEASE ENTER THE MANAGER PASSWORD
510y
          1
"Doesn't exist!!!"

whereas the employee number 1 and user id Admin and password 510y does exist!.

Can someone please tell me where am i doing wrong?
Thanks
Avatar of aik_21
aik_21

ASKER

hey all,
actually i got the answer! for integer variables in comparison i have to use quotes, so it would be "$QYE"
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial