Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh script and db2 variable comparison problem

Status
Not open for further replies.

adev111

Programmer
Jul 8, 2004
44
CA
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"

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!. and it echoes the value back to be 1 but not comparing it right!

Can someone please tell me where am i doing wrong?
Thanks
 
adev111,

#!/usr/bin/ksh
db2 connect to gregs5d1
greg=`db2 -x "select count(*) from sysibm.sysdummy1"`
echo $greg
if [[ $greg -eq 1 ]]
then
echo "its one"
fi

I got the following to work. Main difference being square brackets and the -eq as opposed to =.

Cheers
Greg

ps my mate Adam helped me here!
 
ooops,
i put reply for this on my other question :D
 
adev111,

Glad your sorted, however can you point me to where you're talking about for your reply please. I have looked at your 6 db2 threads and still fail to spot your alternative solution. Did you post it in a different forum or am I simply making a mistake here? Probalbly the latter.

Cheers
Greg

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top