sending output of command via email


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sending output of command via email
# 1  
Old 02-24-2011
sending output of command via email

Hi all

i want to send the output of a command by email, i have done this

<comand> | mail -s <subject> <email address>

which works well, but if the command retunrs noting then i just get a blank email, is there a way to stop this

thanks

Adam
# 2  
Old 02-24-2011
Try:
Code:
command > file.tmp
mailx -s "Subject" mailaddress <file.tmp
rm file.tmp


Last edited by Franklin52; 02-25-2011 at 03:42 AM.. Reason: Please use code tags, thank you
# 3  
Old 02-24-2011
i tired that

i get this as an output now

Code:
Null message body; hope that's ok

but i still get a blank email

does it matter that i am using grep -v to exclude something form the command return
# 4  
Old 02-24-2011
Well try first just the output of the command,
and if it works start eliminating things, till you find where it stucks
# 5  
Old 02-24-2011
Building on previous posts
Code:
command > file.tmp
if [ -s file.tmp ]
then
       mailx -s "Subject" mailaddress <file.tmp
fi
rm file.tmp

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending sql output to email body with conditional subject line

hi , i have written below piece of code to meet the requirement but i am stuck in the logic here. the requirement are: 1) to send the sql out put to email body with proper formatting. 2) if count_matching = Yes then mail should triggered with the subject line ... (10 Replies)
Discussion started by: itzkashi
10 Replies

2. Shell Programming and Scripting

UNIX command output format in email is not same as on the system

Hi I have script to collect file system usage statistics from few remote unix hosts and email . On the UNIX system the column spacing is fine but the email output is not aligned properly. Any tips to fix this ? (1 Reply)
Discussion started by: new2prog
1 Replies

3. Shell Programming and Scripting

Send output of a command as an email

Hello Unix Experts! We are on AIX 6.1 TL6 I am trying to develop a script that does the following: It should send the output of "df -g /directory/folder" command as an email to a user(someone@company.com) This is too simple and i can research on how to do it, but it would be great if... (2 Replies)
Discussion started by: atechcorp
2 Replies

4. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

5. AIX

Sending script output as email

Hi i have a script which executes daily through cron. The output of the script is appended to a log file everyday It also emails me the output of the logfile as we have the mailx command in the script The below is my requirement : Normally When I get the email it sends the entire content... (3 Replies)
Discussion started by: newtoaixos
3 Replies

6. UNIX for Dummies Questions & Answers

Sending output of one command to several others?

I know how I can pipe any output to another command thats easy |. What i'm trying to do is send several addresses to the same command over and over again. Essentially what I want to do is do an nslookup on an address and then take the resulting IP(s) and send each of those IP's to another... (2 Replies)
Discussion started by: MrEddy
2 Replies

7. Shell Programming and Scripting

filtering and sending sar output via email

We have a program which create sar output files which has a weeks data... To read file we use sar -f sa15 command which has multiple days data( a weeks data)....we need to only get last 48 hours data and email it to different users.... I guess we can use combination of sar -o or even awk.... (3 Replies)
Discussion started by: noorm
3 Replies

8. Shell Programming and Scripting

Sending find command results to email

This is probably simple so forgive me... I just want to find all files in a folder created within the last 10 minutes... This is easy: # find /home/folder -cmin -10 If the find command locates any files created in the last ten minutes I want it to send an email alert. I just want to... (3 Replies)
Discussion started by: gardellap
3 Replies

9. UNIX for Dummies Questions & Answers

sending email

hi, is there any possiblity to send email from the command prompt, for eg i want to send alert to any mail id like /data/logs is 80% to my hotmail account , xxx@hotmail.com is this really possible,, if not, then what are the prerequistes need to do this (1 Reply)
Discussion started by: vasikaran
1 Replies
Login or Register to Ask a Question