ERROR in executing mysql querys in shell scripting

Hi All,

Please see the below script for mysql 3 commands. Its giving me the right output for all three commands but showing some errors in first two commands , i guess there might be an issue with date.

Can anyone help me .

#! /bin/bash
TABLE_NAME=testingddatabase
USER_NAME=root
IP_ADDR=111.20.10.235
PW=version
 
$XLN_count=$( mysql -h "$IP_ADDR" -u "$USER_NAME" -p$PW "$TABLE_NAME" -BNe"SELECT count(*) FROM alet where mic='XLN' and alettimestamp>='2012-03-28'")
echo $XLN_count
date=2012-03-29
$XLON_count2=$( mysql -h "$IP_ADDR" -u "$USER_NAME" -p$PW "$TABLE_NAME" -BNe"SELECT count(*) FROM instdata where marketdate>='$date' and insttid in(SELECT insttid FROM insttsymbol where mic='XLN')" )
#echo $XLON_count2
somevar=$( mysql -h "$IP_ADDR" -u "$USER_NAME"  -p$PW "$TABLE_NAME" -BNe"select aletid from alet where aletid='2724'" )
echo $somevar
 
 

in above all the queries are right, there is no problem.i have tested in database.

below is the output of above script.output which i am getting that is 104 , 1700, 2724 is correct but why it is showing an error at line 8 and line 13.

[user01@PP exercise]$ ./monitoring.sh
./IDCmonitoring.sh: line 8: =104: command not found
./IDCmonitoring.sh: line 13: =1700: command not found
2724
 

Add a set -x at the start of the script and redirect/save the output to some text file. Then search for "=104" and "=1700". Maybe there is an incorrect substitution or some syntax error - whatever, you will find it. If you get no idea of the lines where the error is found, post them using code tags of course.

Start by changing:

$XLN_count=

to

XLN_count=

etc.

Thanks a lot radoulvo, its working

I forgot to edit that value .