Friday, November 19, 2010

Sending e-mail from command line (terminal) in unix/linux

Useful for people who want to have status updates on their scripts. You can send e-mails from unix terminal. I use it to report status on the scripts I'm running. If they are successfully executed or crashed, for example.

mail -s "script finished" fool@bs.com < file.txt
The line above sends a mail to fool@bs.com titled "script finished" and with the contents of file.txt. You can omit the file.txt part and send a small piece of content using "echo" and "|", like this:
echo "ABYSS 3rd  run finished" | mail -s "ABYSS run" fool@bs.com

this sends "ABYSS 3rd run finished" as the content of the e-mail.

No comments:

Post a Comment