Sponsored Content
Top Forums Shell Programming and Scripting Conditional bash/mysql query help Post 302937063 by rbatte1 on Tuesday 3rd of March 2015 05:00:15 AM
Old 03-03-2015
You might be having a problem with the quoting too. Your command has a single quoted input to the mysql but then you single quote within that. You might need to use double quotes for the mysql command or escape all the single quotes.

If you are getting output from your command as it is, then catch it to a file instead of trying to pipe it to the mail command. You can then use the shell test to see if the file contains anything:-
Code:
mysql -e ............ whatever you already have > /tmp/new_msgs
if [ -s /tmp/new_msgs ]
then
   mail -s "An e-mail subject" user@email.com < /tmp/new_msgs
fi


Does this help?


Robin
This User Gave Thanks to rbatte1 For This Post:
 

8 More Discussions You Might Find Interesting

1. Programming

How to query one to many mysql

Hi there, I have a hierarchical database that include 4 tables. Table A is the parent of B, B is Parent of C, C is parent of D. If I want to query everything in D that is associated with A.name, how do I do that? Thanks! YanYan (0 Replies)
Discussion started by: pinkgladiator
0 Replies

2. Shell Programming and Scripting

mysql help : query with 2 conditionals

Hi there, I have a table that stores multiple records for many different servers, each of which is timestamped ... I wanted to write a query that would enable me to only output the "latest" record (based on timestamp) for each "unique" server. So for example my main table looks like this ... (3 Replies)
Discussion started by: hcclnoodles
3 Replies

3. Shell Programming and Scripting

bash assign mysql query single field to variable

I'm running a bash script query and assigning the output to a variable like this: exists=`mysql -u $USER_NAME --password=$PASSWORD -D "somedb" \ -e "SELECT * FROM somedb.sometable WHERE field1 ='$a' \ AND field2 ='$b' LIMIT 0 , 30";` which returns something like: echo... (2 Replies)
Discussion started by: unclecameron
2 Replies

4. Web Development

Complex MySQL Query(s)

Hi all, I have a bit of an issue, I am working on a bit of a CMDB for a friend, it's to do with real estate. Anyway, this is my situation. I have a table which contains all the properties (forsale, sold, etc) in the DB named "property". Now, this is what I want to achieve, I wish to... (5 Replies)
Discussion started by: STOIE
5 Replies

5. Web Development

mysql query help

hello all i have 2 columns every column in the following format column1 2011-04-01 11:39:54 column2 2019-02-03 00:00:00 i want get difference between above data as following 2 days 11:39 how to do so ? i tried many functions but nothing works please advice what is the query... (6 Replies)
Discussion started by: mogabr
6 Replies

6. Programming

mysql query help

Hello i have created mysql query to compare to values and get difference in percentage as following: SELECT file_name, 100 - ((100 * (SELECT file_count FROM xipi_files z WHERE x.file_group = z.file_group AND x.file_name = z.file_name AND z.insert_date = CURDATE( ) - INTERVAL 1 DAY)) /... (1 Reply)
Discussion started by: mogabr
1 Replies

7. Shell Programming and Scripting

Conditional emailing with mysql query

Hi, Im new with bash scripting and I want to create a conditional emailing with bash scripting. But it doesn't workout. the conditional requirement are; if the TextDecoded value from inbox table are not the same with sms_keyword value from kontak_group table then don't email. It keep... (10 Replies)
Discussion started by: jazzyzha
10 Replies

8. Programming

Need help in mysql query

Hi All, i have a table in mysql with the following data Table name Test Assettype Serial_No Status location Mouse 123456 In Stock chennai Mouse 98765 Allocated chennai Keyboard ... (2 Replies)
Discussion started by: venkitesh
2 Replies
MYSQL_CONFIG(1) 					       MySQL Database System						   MYSQL_CONFIG(1)

NAME
mysql_config - get compile options for compiling clients SYNOPSIS
mysql_config options DESCRIPTION
mysql_config provides you with useful information for compiling your MySQL client and connecting it to MySQL. mysql_config supports the following options. o --cflags Compiler flags to find include files and critical compiler flags and defines used when compiling the libmysqlclient library. The options returned are tied to the specific compiler that was used when the library was created and might clash with the settings for your own compiler. Use --include for more portable options that contain only include paths. o --include Compiler options to find MySQL include files. o --libmysqld-libs, --embedded Libraries and options required to link with the MySQL embedded server. o --libs Libraries and options required to link with the MySQL client library. o --libs_r Libraries and options required to link with the thread-safe MySQL client library. o --plugindir The default plugin directory path name, defined when configuring MySQL. This option was added in MySQL 5.1.24. o --port The default TCP/IP port number, defined when configuring MySQL. o --socket The default Unix socket file, defined when configuring MySQL. o --variable=VAR Path to MySQL include, library and plugin directories. VAR is one of `pkgincludedir`, `pkglibdir` and `plugindir`, respectively. o --version Version number for the MySQL distribution. If you invoke mysql_config with no options, it displays a list of all options that it supports, and their values: shell> mysql_config Usage: /usr/local/mysql/bin/mysql_config [options] Options: --cflags [-I/usr/local/mysql/include/mysql -mcpu=pentiumpro] --include [-I/usr/local/mysql/include/mysql] --libs [-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -lssl -lcrypto] --libs_r [-L/usr/local/mysql/lib/mysql -lmysqlclient_r -lpthread -lz -lcrypt -lnsl -lm -lpthread] --socket [/tmp/mysql.sock] --port [3306] --version [4.0.16] --libmysqld-libs [-L/usr/local/mysql/lib/mysql -lmysqld -lpthread -lz -lcrypt -lnsl -lm -lpthread -lrt] You can use mysql_config within a command line to include the value that it displays for a particular option. For example, to compile a MySQL client program, use mysql_config as follows: shell> CFG=/usr/local/mysql/bin/mysql_config shell> sh -c "gcc -o progname `$CFG --include` progname.c `$CFG --libs`" When you use mysql_config this way, be sure to invoke it within backtick ("`") characters. That tells the shell to execute it and substitute its output into the surrounding command. COPYRIGHT
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/. SEE ALSO
For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online at http://dev.mysql.com/doc/. AUTHOR
Sun Microsystems, Inc. (http://www.mysql.com/). MySQL 5.1 04/06/2010 MYSQL_CONFIG(1)
All times are GMT -4. The time now is 07:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy