LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   mail command (https://www.linuxquestions.org/questions/linux-general-1/mail-command-443586/)

ksakamuri 05-10-2006 04:23 PM

mail command
 
Hi there,

I want to send and email what ever the command out put i see in the console.

for example: ls -al | tee out; cat out | mail test@bla.com this will work but is there any better way ?

demian 05-10-2006 04:26 PM

ls -la | mail test@bla.com ;)

ksakamuri 05-11-2006 08:04 AM

sorry for not being clear on the question. I also want to see the out put on the screen before it sends an email.

demian 05-11-2006 09:17 AM

Oh, ok.

In that case your command sequence looks ok. You could do without the "out; cat out" part and pipe the output of tee directly into mail. However, if you want to be able to abort sending the mail, after inspecting the output how about defining an alias like show_n_mail (or something shorter so you don't have to type so much:

alias show_n_mail='tee /tmp/out; echo "Send mail? [y/n]"; read ans; if [ $ans == "y" ]; then cat /tmp/out | mail test@bla.com; fi; rm /tmp/out'

Then you can just pipe any input into show_n_mail:

df -h|show_n_mail


All times are GMT -5. The time now is 12:58 PM.