3

I am trying to run a long bash script overnight to get some data. I wanted to include a script that would automatically e-mail me the files after the scripts are completed. Is there a way to do this using mutt? I want something like below:

sh atoms.sh  
sh angles.sh
mutt -a atoms.dat angles.dat -- [e-mail adress]

Any takers?

EDITS: If there's any other way to achieve this -- "sending multiple attachment to an e-mail address after scripting is finished" -- I'd be very appreciated.

Greg
  • 93
  • 3
  • 9
  • Something like what you propose would work. But it depends a lot on your particular situation - what applications do you have available, how large are the data sets and so on. How to email on the command line depends a lot on what email client you have available and set up for instance. – Janne Jan 31 '12 at 00:24
  • @Janne: The "mutt" that the OP refers to *is* an e-mail client. See http://www.mutt.org/. – ruakh Jan 31 '12 at 00:26
  • @ruakh I know; I assumed he does not want to use mutt specifically or he would simply use it as above. – Janne Jan 31 '12 at 00:28
  • @Janne: But he explicitly asks, "Is there a way to do this using mutt?"; so presumably his problem is that he doesn't know how to tell mutt to send an e-mail using only command-line options, without terminal interaction. Which, come to think of it, is not a programming question. I think I'll suggest that this be moved to superuser.com . . . – ruakh Jan 31 '12 at 00:33
  • You're right of course. Should learn to read questions more carefully. – Janne Jan 31 '12 at 00:36
  • thanks -- I didn't know superuser.com exists. It may worthwhile to check it out. As for the question, I don't have to use mutt if the basic tasks (described above in EDITS) can be achieved. – Greg Jan 31 '12 at 00:38
  • Thanks guys but I solved. what do I do with the original post? – Greg Jan 31 '12 at 00:57
  • You can post your solution as an answer, and then accept it. That will benefit other people needing to do the same thing. – ruakh Jan 31 '12 at 01:01
  • can't really post the answers within 8 hours since my rep is low. but here's the answer ... – Greg Jan 31 '12 at 01:04
  • 2
    sh atoms.sh sh angles.sh mutt -s "data set from atoms.sh" [email address] < ./atom.dat mutt -s "data set from angles.sh" [email address] < ./angles.dat will disable the terminal interaction and send e-mails after the jobs are finished. – Greg Jan 31 '12 at 01:04
  • I added the answer as I nearly missed it. – Chris Seymour Feb 01 '12 at 02:11

2 Answers2

2
sh atoms.sh 
sh angles.sh 
mutt -s "data set from atoms.sh" [email address] < ./atom.dat 
mutt -s "data set from angles.sh" [email address] < ./angles.dat 

will disable the terminal interaction and send e-mails after the jobs are finished

Chris Seymour
  • 83,387
  • 30
  • 160
  • 202
0

-a file [...] Attach a file to your message using MIME. To attach multiple files, separating filenames and recipient addresses with "--" is mandatory, e.g. mutt -a img.jpg *.png -- addr1 addr2.

$ $( sh atoms.sh; sh angles.sh ) &&  mutt -s "man mutt" \
  -a grab.sh  raptor.mpd.ogg.m3u  scripts/bussorakel  \
 -- emailAddress@example.com < /dev/null

alternatively, you have:

$(sh atoms.sh; sh angles.sh ) & FOR=$!
wait $FOR 

mutt -s "last command done, sending email" (...)

the received mail:

  • The question is about how to send an email after jobs has completed and not about attaching files using mutt. –  Feb 24 '12 at 15:25