LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-20-2003, 04:01 AM   #1
pr0fess0r
LQ Newbie
 
Registered: May 2003
Posts: 4

Rep: Reputation: 0
Angry sending attachments from sendmail in a script


Hi Guys

I have a shell script I am going to set up as a cron job. It dumps a MySQL database as a gzipped file. I want it to email that file to another address.

So far the script is:

#!/bin/sh
date=`date -I`
mysqldump --opt -Q -u root --password=***** contented | gzip > /home/username/.gnome-desktop/dbdump-$date.sql.gz

which works nicely

Now how do I send that file to user@domain.com using sendmail? I am on RH Linux 9, but this will eventually go to my ISP which may not be running RH so a generic answer would be great!

Many thanks!
 
Old 05-20-2003, 04:40 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
What you want is a proper formatted MIME message: see mimencode or mpack.
// You could also do with some checks based on the error messages of the dump command, size of the message (use bzip2 vs gzip, or split if too large), use proper quoting (see date), make damn sure the file has the right permissions due to it having the passwd and not put the tmpfile in /home/username/.gnome-desktop, but in a proper temp directory...
 
Old 05-20-2003, 05:49 AM   #3
pr0fess0r
LQ Newbie
 
Registered: May 2003
Posts: 4

Original Poster
Rep: Reputation: 0
Some hints?

Hi

Thanks for the tip. As I'm a newbie, could you give me a "best practise" example of how to fix the previous script (the .gnome-desktop path is just for testing, an ex-Windows user here and how to use mimeencode/sendmail?

cheers
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending attachments using mailx wolfman423 Linux - Newbie 0 10-14-2005 08:27 AM
sendmail - strip attachments - is this possible irubin Linux - Software 1 09-22-2004 08:23 AM
Sendmail & How to reject mail with executable attachments WorldBuilder Linux - Networking 3 02-04-2004 03:27 PM
Automated sending attachments through eamil kevin.mccullor Linux - Newbie 1 07-28-2003 01:15 PM
Sendmail and attachments Satriani Linux - Software 2 04-27-2003 12:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration