Sponsored Content
Operating Systems Linux Gentoo inserting grep -c value into an email subject Post 302220762 by GrendelPrime on Friday 1st of August 2008 01:59:05 PM
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.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

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... (4 Replies)
Discussion started by: mskarica
4 Replies

2. 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}'... (2 Replies)
Discussion started by: deepsingh
2 Replies

3. Shell Programming and Scripting

Run a script based on the subject line of the email

Hi, I need help in running a script that would pull info from an email subject line and run a script (foo.sh). I'm pretty sure after a bit of googling that this is possible in several ways. but none was pretty clear on how to accomplish it. The part that I really need help with is getting the... (5 Replies)
Discussion started by: satekn
5 Replies

4. Shell Programming and Scripting

Unable to populate subject field of the email while using sendmail

Hi, Can anyone kindly provide some information about how to populate the subject field of the email while using the sendmail utility ? Itried the following command line argument : echo -e "Body of the email" | /usr/lib/sendmail -f from@from.com -t to@to.com -s " Subject of the email" ... (4 Replies)
Discussion started by: sdiptanil
4 Replies

5. Shell Programming and Scripting

help with script to send email and if subject line match is found

Help with script that will check log, then find a match is found, add that as the subject line. 1. The script will always run as a deamon.. and scan the event.log file 2. when a new 101 line is added to the event.log file, have the script check position 5,6 and 7 which is the job name, which... (2 Replies)
Discussion started by: axdelg
2 Replies

6. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: smarty86
4 Replies

7. UNIX for Dummies Questions & Answers

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 ... (5 Replies)
Discussion started by: thangaga
5 Replies

8. Shell Programming and Scripting

Sendemail how to send an email with a subject variable

Hi,:) I try this : #!/bin/bash sender="me@example.com" recipient="you@example.com" subject="TEST FILE" server="0.0.0.0" file=$(cat file.txt) /usr/bin/sendemail -f $sender -t $recipient -u $subject -m $file My file.txt: BLABLALA BLABLABLA (7 Replies)
Discussion started by: Arnaudh78
7 Replies

9. Shell Programming and Scripting

Sending sql output to email body with conditional subject line

hi , i have written below piece of code to meet the requirement but i am stuck in the logic here. the requirement are: 1) to send the sql out put to email body with proper formatting. 2) if count_matching = Yes then mail should triggered with the subject line ... (10 Replies)
Discussion started by: itzkashi
10 Replies

10. UNIX for Beginners Questions & Answers

Variable not displaying in subject line of mailx email

Hi Newbie here with first post. I've got a shell script (ksh) whereby I run a SQL*Plus script and output the results to a file. I then check the output file in an if statement that looks like this: if ]; then export GAPNUM=`awk '{print $4}' $OUTFILE` if ] then mailx -s... (10 Replies)
Discussion started by: ltzwoman
10 Replies
amavisd-milter(8)					    BSD System Manager's Manual 					 amavisd-milter(8)

NAME
amavisd-milter -- sendmail milter for amavisd-new SYNOPSIS
amavisd-milter [-fhv] [-d debug-level] [-D delivery-care-of] [-m max-conns] [-M max-wait] [-p pidfile] [-P] [-q backlog] [-s socket] [-t timeout] [-S socket] [-T timeout] [-w directory] DESCRIPTION
The amavisd-milter is a sendmail milter (mail filter) for amavisd-new 2.4.3 and above and sendmail 8.13 and above (limited support for 8.12 is provided). Instead of older amavis-milter helper program, full amavisd-new functionality is available, including adding spam and virus information header fields, modifying Subject, adding address extensions and removing certain recipients from delivery while delivering the same message to the rest. For more information you can visit amavisd-milter website: http://amavisd-milter.sourceforge.net/ and SourceForge project: http://sourceforge.net/projects/amavisd-milter Options The options are as follows: -d debug-level Set the debug level to debug-level. Debugging traces become more verbose as the debug level increases. Maximum is 9. -D delivery-care-of Set AM.PDP request attribute delivery_care_of to client (default) or server. When client method is used then amavisd-milter is responsible to forward the message to recipients. This method doesn't allow personalized header or body modification. When server method is used then amavisd-new is responsible to forward the message to recipients and can provide personalized header and body modification. $forward_method in amavisd.conf must point to some place willing to accept mail without further checking in amavisd-new. -f Run amavisd-milter in the foreground (i.e. do not daemonize). Print debug messages to the terminal. -h Print help page and exit. -m max-conns Maximum concurrent amavisd connections (default 0 - unlimited number of connections). It must agree with the $max_servers entry in amavisd.conf. -M max-wait Maximum wait for connection to amavisd in seconds (default 300 = 5 minutes). It must be less then sending MTA timeout for a response to the final "." that terminates a message on sending MTA. sendmail has default value 1 hour, postfix 10 minutes and qmail 20 min- utes. We suggest to use less than 10 minutes. -p pidfile Use this pid file (default /var/run/amavis/amavisd-milter.pid). -P When amavisd-new fails mail will be passed through unchecked. -q backlog Sets the incoming socket backlog used by listen(2). If it is not set or set to zero, the operating system default is used. -s socket Communication socket between sendmail and amavisd-milter (default /var/lib/amavis/amavisd-milter.sock). The protocol spoken over this socket is MILTER (Mail FILTER). It must agree with the INPUT_MAIL_FILTER entry in sendmail.mc The socket should be in "proto:address" format: o {unix|local}:/path/to/file - A named pipe. o inet:port@{hostname|ip-address} - An IPV4 socket. o inet6:port@{hostname|ip-address} - An IPV6 socket. -S socket Communication socket between amavisd-milter and amavisd-new (default /var/lib/amavis/amavisd.sock). The protocol spoken over this socket is AM.PDP (AMavis Policy Delegation Protocol). It must agree with the $unix_socketname entry in amavisd.conf. The socket should be in "proto:address" format: o {unix|local}:/path/to/file - A named pipe. -t timeout sendmail connection timeout in seconds (default 600 = 10 minutes). It must agree with the INPUT_MAIL_FILTER entry in sendmail.mc and must be greater than or equal to the amavisd-new connection timeout. When you use other milters (especially time-consuming), the timeout must be sufficient to process message in all milters. -T timeout amavisd-new connection timeout in seconds (default 600 = 10 minutes). This timeout must be sufficient for message processing in amavisd-new. It's usually a good idea to adjust them to the same value as sendmail connection timeout. -v Report the version number and exit. -w directory Set working directory (default /var/lib/amavis/tmp). Limited support for sendmail 8.12 o smfi_addheader() is used instead of smfi_insheader() for insheader and addheader AM.PDP responses. This works well with amavisd-new 2.4.3 or newer. o smfi_progress() isn't called when amavisd-milter wait for amavisd-new communication socket. o AM.PDP response quarantine isn't implemented. FILES
/var/run/amavis/amavisd-milter.pid The default process-id file. /var/lib/amavis/amavisd-milter.sock The default sendmail communication socket. /var/lib/amavis/amavisd.sock Th default amavisd-new communication socket. /var/lib/amavis/tmp The default working directory. POLICY BANK
When remote client is authenticated, amavisd-milter forward this information to amavisd-new through AM.PDP request attribute policy_bank: SMTP_AUTH Indicate that the remote client is authenticated. SMTP_AUTH_<MECH> Remote client authentication mechanism. SMTP_AUTH_<MECH>_<BITS> The number of bits used for the key of the symmetric cipher when authentication mechanism use it. EXAMPLES
Configuring amavisd-new In amavisd.conf file change protocol and socket settings to: $protocol = "AM.PDP"; # Use AM.PDP protocol $unix_socketname = "$MYHOME/amavisd.sock"; # Listen on Unix socket ### $inet_socket_port = 10024; # Don't listen on TCP port Then (re)start amavisd daemon. Configuring sendmail To the sendmail.mc file add the following entries: define(`confMILTER_MACROS_ENVFROM', confMILTER_MACROS_ENVFROM`, r, b') INPUT_MAIL_FILTER(`amavisd-milter', `S=local:/var/lib/amavis/amavisd-milter.sock, F=T, T=S:10m;R:10m;E:10m') Then rebuild your sendmail.cf file, install it (usually to /etc/mail/sendmail.cf) and (re)start sendmail daemon. Running amavisd-milter This example assume that amavisd-new is running as user amavis. It must agree with the entry $daemon_user in amavisd.conf. First create working directory: mkdir /var/lib/amavis/tmp chmod 750 /var/lib/amavis/tmp chown amavis /var/lib/amavis/tmp Then start amavisd-milter as non-priviledged user amavis: su - amavis -c "amavisd-milter -w /var/lib/amavis/tmp" Limiting maximum concurrent connections to amavisd To limit concurrent connections to 4 and fail after 10 minutes (10*60 secs) of waiting run amavisd-milter with this options: su - amavis -c "amavisd-milter -w /var/lib/amavis/tmp -m 4 -M 600" Troubleshooting For troubleshooting run amavisd-milter on the foreground and set debug level to appropriate level: su - amavis -c "amavisd-milter -w /var/lib/amavis/tmp -f -d level" where debug levels are: 1 Not errors but unexpected states (connection abort etc). 2 Main states in message processing. 3 All amavisd-milter debug messages. 4-9 Milter communication debugging (smfi_setdbg 1-6). SEE ALSO
http://amavisd-milter.sourceforge.net http://www.ijs.si/software/amavisd/ http://www.milter.org/developers http://www.sendmail.org AUTHORS
This manual page was written by Petr Rehor <rx@rx.cz> and is based on Jerzy Sakol <jerzy.sakol@commgraf.pl> initial work. BUGS
A community mailing lists are available at: http://sourceforge.net/mail/?group_id=138169 Enhancements, requests and problem reports are welcome. If you run into problems first check the users mailing list archive before asking questions on the list. It's highly likely somebody has already come across the same problem and it's been solved. BSD
Januar 23, 2006 BSD
All times are GMT -4. The time now is 06:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy