inserting grep -c value into an email subject


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 08-01-2008
Question inserting grep -c value into an email subject

I am profoundly new to *nix, but had a project dropped in my lap that has sparked an interest, leading me here.

I was tasked with daily sending one of our customers a listing of all the spam our filter blocked that was heading for them.
Between Google and I;
I discovered the Server is running Linux version 2.6.11-gentoo-r4.
I learned the basics of grep enough to pare down the amavis.log file to only the pertinent data and figured out how to get it mailed out.
I added a crontab to do this daily, and the job was done to the customer's satisfaction.

Unfortunately, I cannot leave well enough alone, and decided I wanted to have the email subject include the total blocked messages.
grep -c Blocked gives me the total, but I have not been able to track down how to modify the mail subject to reflect this.
I attempted to assign n = grep -c Blocked /var/amavis/amavis.log, but $n just echos as grep.


Pointing out where I'm screwing up or directing me to a link where I can find the info would be greatly appreciated.
# 2  
Old 08-01-2008
Code:
n=`grep -c Blocked /var/amavis/amavis.log`

# 3  
Old 08-01-2008
Quote:
Originally Posted by Ikon
Code:
n=`grep -c Blocked /var/amavis/amavis.log`

Just for an FYI, those are back ticks, and not single quotes. This is on the same key as ~.
# 4  
Old 08-01-2008
That makes a huge difference, thank you!

So far, I have used email -s "customer spam report" customer@address.sam to deliver the resulting log, which works.

My goal is to insert my newly created $n value into the subject, ala' "Customer Spam Report ($n messages)".
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Sending sql output to email body with conditional subject line itzkashi Shell Programming and Scripting 10 03-15-2017 04:20 AM
Sendemail how to send an email with a subject variable Arnaudh78 Shell Programming and Scripting 7 09-28-2016 04:30 PM
Search email addresses using grep command ForeignGuy Homework & Coursework Questions 2 09-07-2016 01:23 AM
Grep out ONLY subject from maillog anil510 Shell Programming and Scripting 3 11-15-2013 02:50 AM
Grep the last line and put on mail subject Daniel Gate Shell Programming and Scripting 6 03-06-2013 10:01 PM
Inserting subject for the mails sent through SQR thangaga UNIX for Dummies Questions & Answers 5 04-03-2012 08:17 AM
grep command for email marcuslki UNIX for Dummies Questions & Answers 2 02-15-2012 05:20 PM
Subject line of an email smarty86 Shell Programming and Scripting 4 12-20-2010 02:26 AM
help with script to send email and if subject line match is found axdelg Shell Programming and Scripting 2 07-07-2010 05:43 PM
Unable to populate subject field of the email while using sendmail sdiptanil Shell Programming and Scripting 4 06-25-2010 10:30 PM
Run a script based on the subject line of the email satekn Shell Programming and Scripting 5 04-16-2009 01:11 PM
Script to find, grep and email basisvasis Shell Programming and Scripting 7 09-21-2008 08:03 PM
Grep and Email wakhan Shell Programming and Scripting 7 09-18-2008 02:32 AM
Email with subject contains value of Variable deepsingh Shell Programming and Scripting 2 06-19-2008 05:20 PM
use email subject line as shell command mskarica UNIX for Advanced & Expert Users 4 02-01-2005 12:23 AM