ERROR in executing mysql querys in shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ERROR in executing mysql querys in shell scripting
# 1  
Old 03-29-2012
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 .

Code:
#! /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.

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

# 2  
Old 03-29-2012
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.
# 3  
Old 03-29-2012
Start by changing:

Code:
$XLN_count=

to
Code:
XLN_count=

etc.
# 4  
Old 03-30-2012
Thanks a lot radoulvo, its working

I forgot to edit that value .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error while executing the shell script

Hi Gurus, The following script fails with the error 'command not found' while trying to execute. As the error indicates, the script fails at ROW#30 where the EOF is defined for SQL statement. It appears that the script is trying execute the lines in the SQL output written to ta spool file.... (7 Replies)
Discussion started by: svajhala
7 Replies

2. Shell Programming and Scripting

error when executing shell scrpit

Guys, when i am executing the following script I am getting following error. -bash: test.sh: command not found $ test.sh -- script name #! /bin/bash echo " Job started........" CURRENTDIR=`pwd` exit 0 thanks Please view this link: How to use ... tags (2 Replies)
Discussion started by: skatpally
2 Replies

3. Shell Programming and Scripting

Debugging mode while executing Unix Shell Scripting

Hi, Is there any debugging tool for Unix Shell Script like we have gdb in C/C++? Also please let me know how to close the thread is it automatic or we have to close it manually. Thanks and Regards (1 Reply)
Discussion started by: diehard
1 Replies

4. Shell Programming and Scripting

Strategical Shell Scripting For MySql Replication

Hi to all guyz , As i'm new to Shell scripting i was been working out to write a shell script for mysql Replication for multiple slave master architecture.i have done the process up with a script of 200 lines but still there are some things which can make my script more effective so i want your... (5 Replies)
Discussion started by: kgrvamsi
5 Replies

5. Linux

Error executing shell script in Linux

Hi, I have following shell script code : ------------------------------------------------------------------ #!/bin/bash SCRIPTS_DIR="/scriptsDir1" # tables login/password APIL_USER="uname/pswd" I2_USER="uname/pswd" # Database DB="db1" cd "$SCRIPTS_DIR/scriptsDir2" sqlplus... (1 Reply)
Discussion started by: Chaitrali
1 Replies

6. Shell Programming and Scripting

Error executing shell script in Linux

Hi, I have following shell script code : ------------------------------------------------------------------ #!/bin/bash SCRIPTS_DIR="/scriptsDir1" # tables login/password APIL_USER="uname/pswd" I2_USER="uname/pswd" # Database DB="db1" cd "$SCRIPTS_DIR/scriptsDir2" sqlplus... (2 Replies)
Discussion started by: Chaitrali
2 Replies

7. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies

8. Shell Programming and Scripting

shell scripting on unix/mysql problems

Hi, I have written a shell script for oracle on unix that does a df for specific files, and then will display the size, Avail, % used and the difference from yesterday to today. I have been asked to place it on some MySql databases that run onn unix and linux also, but when I try to run them I... (2 Replies)
Discussion started by: cat55
2 Replies

9. Shell Programming and Scripting

executing mysql load statement from shell script

Hi, I have a piece of shell script which will connect to mysql database and execute a load statement(which will load datas in a file to the database table).The code is working and the data is in the tables. Now my requirement is, i need to grab the output from the load statement... (4 Replies)
Discussion started by: DILEEP410
4 Replies

10. Shell Programming and Scripting

Error message while executing the shell script

Hi All, When I am trying to execute the below shell script I got this error message. script ========== #!/bin/bash /usr/java/jdk1.5.0_10/bin/java - classpath /var/lib/asterisk/agi-bin/mysql-connector-java-3.0.15-ga-bin.jar/: /var/lib/asterisk/agi-bin/jarfiles:... (4 Replies)
Discussion started by: ajayyaduwanshi
4 Replies
Login or Register to Ask a Question