The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
send email from address list and subject list paulds UNIX for Dummies Questions & Answers 2 06-27-2008 07:11 AM
Email with subject contains value of Variable deepsingh Shell Programming and Scripting 2 06-19-2008 01:20 PM
How to set Subject in 'mail' ? hkapil UNIX for Dummies Questions & Answers 2 10-14-2005 01:36 PM
use email subject line as shell command mskarica UNIX for Advanced & Expert Users 4 01-31-2005 09:23 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-01-2008
Registered User
 

Join Date: Aug 2008
Posts: 3
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.
Reply With Quote
Forum Sponsor
  #2  
Old 08-01-2008
Ikon's Avatar
Registered User
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 414
Code:
n=`grep -c Blocked /var/amavis/amavis.log`
Reply With Quote
  #3  
Old 08-01-2008
Registered User
 

Join Date: May 2008
Posts: 77
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 ~.
Reply With Quote
  #4  
Old 08-01-2008
Registered User
 

Join Date: Aug 2008
Posts: 3
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)".
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0