Unix/Linux Go Back    


Gentoo Gentoo Linux is a versatile and fast, completely free Linux distribution geared towards developers and network professionals.

inserting grep -c value into an email subject

Gentoo


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-01-2008
GrendelPrime GrendelPrime is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 4 August 2008, 8:30 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Unix or Linux 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.
Sponsored Links
    #2  
Old Unix and Linux 08-01-2008
Ikon's Unix or Linux Image
Ikon Ikon is offline Forum Advisor  
Computer Geek
 
Join Date: Jul 2008
Last Activity: 15 January 2015, 10:57 AM EST
Location: Frederick, MD
Posts: 748
Thanks: 4
Thanked 11 Times in 10 Posts

Code:
n=`grep -c Blocked /var/amavis/amavis.log`

Sponsored Links
    #3  
Old Unix and Linux 08-01-2008
mark54g mark54g is offline Forum Advisor  
Registered User
 
Join Date: May 2008
Last Activity: 26 July 2013, 11:43 AM EDT
Location: Northeastern United States
Posts: 918
Thanks: 1
Thanked 61 Times in 58 Posts
Quote:
Originally Posted by Ikon View Post
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 Unix and Linux 08-01-2008
GrendelPrime GrendelPrime is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 4 August 2008, 8:30 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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)".
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Inserting subject for the mails sent through SQR thangaga UNIX for Dummies Questions & Answers 5 04-03-2012 08:17 AM
Subject line of an email smarty86 Shell Programming and Scripting 4 12-20-2010 02:26 AM
Run a script based on the subject line of the email satekn Shell Programming and Scripting 5 04-16-2009 01:11 PM
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



All times are GMT -4. The time now is 01:15 PM.