Link to home
Start Free TrialLog in
Avatar of kevandju
kevandjuFlag for United States of America

asked on

Bash script to email me data from MySQL on Linux server

I have a View that I created on my MySQL database that I would like emailed to me daily so I can monitor some data.  I just have no idea on how to write a script to do this.  Can anyone help?
Avatar of nabeelmoidu
nabeelmoidu
Flag of United States of America image

echo " MYSQL_STATEMENT" | mysql -u username -p  password   >> /path/to/file
mail -s 'Daily DB Check - MySQL View'  username@mail.domain.tld < /path/to/file
ASKER CERTIFIED SOLUTION
Avatar of arober11
arober11
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevandju

ASKER

Sorry for the delay on responding.  Arober is there a way that I can just have the results placed in the body of the email rather than an attachment?
#Attach the extracted file to an email, then delete it.
uuencode $TMP_FIR/$CSV_FL_NAME $CSV_FL_NAME |

Can be changed to

uuencode $TMP_FIR/$CSV_FL_NAME $CSV_FL_NAME;
mailx $MAILX_REP $REPLY_TO -s "$SUBJECT_LINE" $MAIL_TO < $CSV_FL_NAME;
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial