Sponsored Content
Top Forums Shell Programming and Scripting Shell script automation using cron which query's MySQL Tables Post 303023605 by kkpand on Wednesday 19th of September 2018 04:19:26 PM
Old 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

Tables to query to find users for database from shell script

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

Passing a variable from shell script to mysql query?

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

Help with Shell Script automation

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

Query Oracle tables and return values to shell script that calls the query

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

Help with Truststore automation shell script

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

Using a shell script variable in a mysql query using 'LIKE'

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

mysql query for multiple columns from multiple tables in a DB

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

Shell Script to execute Oracle query taking input from a file to form query

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

Using bash script : How to Import data from a dsv file into multiple tables in mysql

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
svm-subset(1)							   User Manuals 						     svm-subset(1)

NAME
svm-subset - a subset selection tool for LIBSVM SYNOPSIS
svm-subset [ -s method ] dataset number [ output1 ] [ output2 ] DESCRIPTION
Training large data is time consuming. Sometimes one should work on a smaller subset first. The python script subset.py randomly selects a specified number of samples. For classification data, we provide a stratified selection to ensure the same class distribution in the sub- set. OPTIONS
-s method 0 -- stratified selection (classification only) (default) 1 -- random selection output1 The subset. If output1 is omitted, the subset will be printed on the screen. output2 The rest of data. FILES
See svm-train(1) for the format of dataset EXAMPLES
svm-subset heart_scale 100 file1 file2 From heart_scale 100 samples are randomly selected and stored in file1. All remaining instances are stored in file2. BUGS
Please report bugs to the Debian BTS. AUTHOR
Chih-Chung Chang, Chih-Jen Lin <cjlin@csie.ntu.edu.tw>, Chen-Tse Tsai <ctse.tsai@gmail.com> (packaging) SEE ALSO
svm-train(1), svm-predict(1) Linux DEC 2009 svm-subset(1)
All times are GMT -4. The time now is 09:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy