LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-10-2006, 04:23 PM   #1
ksakamuri
LQ Newbie
 
Registered: May 2006
Posts: 4

Rep: Reputation: 0
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 ?
 
Old 05-10-2006, 04:26 PM   #2
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
ls -la | mail test@bla.com
 
Old 05-11-2006, 08:04 AM   #3
ksakamuri
LQ Newbie
 
Registered: May 2006
Posts: 4

Original Poster
Rep: Reputation: 0
sorry for not being clear on the question. I also want to see the out put on the screen before it sends an email.
 
Old 05-11-2006, 09:17 AM   #4
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
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
 
  


Reply



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
Cannot send mail with mail() command in PHP 4.3.4, Apache 2.0.48, Mandrake Linux 10 arcanum Linux - General 3 06-27-2004 06:06 PM
mail command ? johnyy Linux - Software 2 12-05-2003 12:29 AM
mail is not delivered thru the mail command aadilkhan Linux - General 1 11-18-2003 05:37 PM
cannot receive mail -- mail command andy18 Linux - General 1 09-09-2003 03:13 PM
Using the 'mail' command to mail a file Crashed_Again Linux - Software 2 08-08-2003 05:19 AM

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

All times are GMT -5. The time now is 11:52 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