Wednesday, April 13, 2011

Linux send mail attachements

Whats are the possible ways to send and email attachment - say needed to embedded in a script or something. May be attachment of the error/debug logs, that your script generated.

Well i can think of -

  • mutt -s "demo email attachement" -a cvs6bld.php < body.txt
  • uuencode bgraph.php | mail -s "demo email attachement" < body.txt
Note: uuencode is a utility which come with sharutils rpm package.
  • mailx -s "demo email attachement" < cvs6bld.php

However the one with mailx command, is NOT a mime attachment - it's just your file content mixed in to the mail message body. Some e-mail clients will see it and might treat it as a real attachment, so we might be good.

Comments below are welcome- if you have tried some other raw way! :-)


capture debug log of my bash script


export PS4='$0.$LINENO+ '
exec > /tmp/TTpull.log
exec 2>&1
set -x

This is how I like to capture - now what those above means?

The PS4 i already explained in my previous post. The $0 variable holds the name of the script. $LINENO displays the current line no. within the script. The exec command redirects I/O streams. to a file /tmp/TTpull.log. 2>&1 redirects stderr and stdout. and finally - 'set -x' enables debugging.


Why Database CI/CD?

Making the Database Part of Your Continuous Delivery Pipeline The database, unlike other software components and code or compiled co...