09-19-2018
Shell script automation using cron which query's MySQL Tables
What I have:
I have a input.sh (script which basically connect to mysql-db and query's multiple tables to write back the output to output1.out file in a directory)
note: I need to pass an integer (unique_id = anything b/w 1- 1000) next to the script everytime I run the script which generates output file by that integer I passed (output1.out, output2.out .... etc....)
I simply run this command now: sh input.sh 88 |mysql -h XXXX -u XXXX -p XXXX ---> this writes back the output(output1.out) file to a location.
What I require:
I want to write a wrapper script and schedule with a cron job --
to run this script daily with multiple unique_id's at once and writes out the output files with respective unique_id numbers ( output1.out, output2.out etc..) and send the resulting output file (output1.out) as an attachment to an email distribution list..
The format of the output file should: more manageable, for example, the email recipients(users) can change the format so it can be read/edited in excel, add a column for action.
o/p file to send in email, for example:
output1.out --- email1.abc.com
output2.out --- email2.xyz.com etc....
please let me know how does this works - let me know in detail steps (kind of new to crontab)
Thanks in Advance
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am coding shell script.
I need to connect to different databases like DB2, Oracle and Sybase.
I would then need to query tables where it has all the groups, users for that database.
I would also need who has what kind of permissions.
EG: I know for DB2 some TABAUTH table needs to be... (0 Replies)
Discussion started by: pinnacle
0 Replies
2. Shell Programming and Scripting
I heard this was possible but from my research I haven't been able to figure it out yet. Seems it should be simple enough. Basically from a high level view I'm trying to accomplish...
. $X='grep foo blah.log'
then 'mysql command SELECT foo FROM bar WHERE ' . $X
or something like that.
... (2 Replies)
Discussion started by: kero
2 Replies
3. Shell Programming and Scripting
can someone look into this one please... I am struck at this point. I do not know what logic to be followed here. I can go ahead with my work only, if this step is done. Please Help.
I have a process X in a shell script. Once the process X is done, it generates a log file. Process X is basically... (1 Reply)
Discussion started by: ss3944
1 Replies
4. Shell Programming and Scripting
Hi,
I have a requirement as below which needs to be done viz UNIX shell script
(1) I have to connect to an Oracle database
(2) Exexute "SELECT field_status from table 1" query on one of the tables.
(3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies
5. Shell Programming and Scripting
Please close this thread.
I have raise this question in appropriate thread.
Thanks (0 Replies)
Discussion started by: KuldeepSinghTCS
0 Replies
6. Shell Programming and Scripting
Hello. I am writing a simple script that reads a text file and removes records from a mysql database. The items in the text file are of the format:
firstname.middle.lastXXX, where XXX is a 3 digit number. The table has an email field that will match the firstname.middle.last. So, I thought I... (1 Reply)
Discussion started by: bricoleur
1 Replies
7. Web Development
Say I have two tables like below..
status
HId sName dName StartTime EndTime
1 E E 9:10 10:10
2 E F 9:15 10:15
3 G H 9:17 10:00
logic
Id devName capacity free Line
1 E 123 34 1
2 E 345 ... (3 Replies)
Discussion started by: ilan
3 Replies
8. Shell Programming and Scripting
Hi,
I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database.
For instance:
USER CITY
--------- ----------
A CITY_A
B CITY_B
C ... (2 Replies)
Discussion started by: DevendraG
2 Replies
9. UNIX for Beginners Questions & Answers
HI
I have a dsv file that looks like:
<<BOF>>
record_number|id_number|first name|last name|msisdn|network|points|card number|gender
312|9101011234011|Test Junior|Smith|071 123 4321|MTN|73|1241551413214444|M
313|9012023213011|Bob|Smith|27743334321|Vodacom|3|1231233232323244|M... (4 Replies)
Discussion started by: tera
4 Replies
LEARN ABOUT SUSE
mysqlbug
MYSQLBUG(1) MySQL Database System MYSQLBUG(1)
NAME
mysqlbug - generate bug report
SYNOPSIS
mysqlbug
DESCRIPTION
This program enables you to generate a bug report and send it to Oracle Corporation. It is a shell script and runs on Unix.
The normal way to report bugs is to visit http://bugs.mysql.com/, which is the address for our bugs database. This database is public and
can be browsed and searched by anyone. If you log in to the system, you can enter new reports. If you have no Web access, you can generate
a bug report by using the mysqlbug script.
mysqlbug helps you generate a report by determining much of the following information automatically, but if something important is missing,
please include it with your message. mysqlbug can be found in the scripts directory (source distribution) and in the bin directory under
your MySQL installation directory (binary distribution).
Invoke mysqlbug without arguments:
shell> mysqlbug
The script will place you in an editor with a copy of the report to be sent. Edit the lines near the beginning that indicate the nature of
the problem. Then write the file to save your changes, quit the editor, and mysqlbug will send the report by email.
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 MYSQLBUG(1)