Home Man
Search
Today's Posts
Register

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

Tags
email, grep, subject

Login 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 to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sending sql output to email body with conditional subject line itzkashi Shell Programming and Scripting 10 03-15-2017 03:20 AM
Sendemail how to send an email with a subject variable Arnaudh78 Shell Programming and Scripting 7 09-28-2016 03:30 PM
Inserting subject for the mails sent through SQR thangaga UNIX for Dummies Questions & Answers 5 04-03-2012 07:17 AM
Subject line of an email smarty86 Shell Programming and Scripting 4 12-20-2010 01:26 AM
help with script to send email and if subject line match is found axdelg Shell Programming and Scripting 2 07-07-2010 04:43 PM
Unable to populate subject field of the email while using sendmail sdiptanil Shell Programming and Scripting 4 06-25-2010 09:30 PM
Run a script based on the subject line of the email satekn Shell Programming and Scripting 5 04-16-2009 12:11 PM
Grep and Email wakhan Shell Programming and Scripting 7 09-18-2008 01:32 AM
Email with subject contains value of Variable deepsingh Shell Programming and Scripting 2 06-19-2008 04:20 PM
use email subject line as shell command mskarica UNIX for Advanced & Expert Users 4 01-31-2005 11:23 PM


All times are GMT -4. The time now is 06:02 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password