Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.

inserting grep -c value into an email subject

Login or Register to Reply

Thread Tools Search this Thread
# 1  
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  
n=`grep -c Blocked /var/amavis/amavis.log`

# 3  
Originally Posted by Ikon
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  
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
Sendemail how to send an email with a subject variable
Hi,:) I try this : #!/bin/bash sender="" recipient="" subject="TEST FILE" server="" file=$(cat file.txt) /usr/bin/sendemail -f $sender -t $recipient -u $subject -m $file My file.txt: BLABLALA BLABLABLA... Shell Programming and Scripting
Shell Programming and Scripting
Inserting subject for the mails sent through SQR
I am trying to insert subject for the mails sent through one of our sqr process using below code Let $Email_Command = 'uuencode ' || $filename || ' ' || $filename || ' | sendmail -F''' ||$subject || ''' ' ||$mailid1 || ''' ' ||$mailid2 CALL SYSTEM USING $Email_Command #return_code WAIT ...... UNIX for Dummies Questions & Answers
UNIX for Dummies Questions & Answers
Subject line of an email
Hi all, I am trying to automate a process in which at the end of the process the script should send an email to the user saying this process is completed. I have done everything but the problem now is the subject line of the email... the subject line looks like this.. where abc xyz is a...... Shell Programming and Scripting
Shell Programming and Scripting
Email with subject contains value of Variable
I want to email where subject contains value of variable $ORACLE_SID. When script is emailing, it is not taking value of $ORACLE_SID. example - I have variable ORACLE_SID=prd I am sending email with below script. tail -1 $LOG | mailx -s 'Export Completed for ${ORACLE_SID}'...... Shell Programming and Scripting
Shell Programming and Scripting
use email subject line as shell command
If anyone can give me some ideas on this it would be great. What I'm trying to do is to have emails be sent to my unix account. Once they are emailed to the unix account, I want to use the text in the subject field to invoke a shell script, so basically I need to find a way that I can...... UNIX for Advanced & Expert Users
UNIX for Advanced & Expert Users

Featured Tech Videos