Questions about Writing scripts for filter message

Questions about Writing scripts for filter message

Post by guohong ca » Fri, 11 Oct 1996 04:00:00

I want to write a script to filter the coming E-mail.
People may send me mail simultaneouslly, I have to use the lock function.
The following is the script which is executed by changing .forward:

lockfile process_mail/temp_mail.lock
cat > process_mail/temp_mail
grep -i "cis294j" process_mail/temp_mail | cat >process_mail/goodmail

if (test -s  process_mail/goodmail) then
   cat  process_mail/temp_mail >> process_mail/cis294j

   cat  process_mail/temp_mail >> process_mail/gcao

rm -f process_mail/temp_mail.lock

I tested it by sending 40 mails at the same time, it loses two or three
mails. I don't know what's wrong with the lockfile.

Failing to solve the problem, I want to use procmail.
The following is part of my procmailrc:
(/usr/lib/sendmail is also $SENDMAIL)

:0 h c
*  ^Subject.*cis294
| (formail -r -A"Precedence: junk";\
              echo "Mail received.") | /usr/lib/sendmail -t
:0 A

By this, it should auto-reply to the sender, and save a
copy to cis294. I can find the coming mail in cis294,
but it did not send reply message.




1. syslog - how 2 filter messages before writing 2 disk

i need to filter in some way messages which comes to syslogd, and
depenging on some rules write them to 2 diferent files.
i was thinking about something like this:
#part of /etc/syslogd.conf
local0.debug    /vat/log/logfile

#part of script
tail -f /var/log/logfile | grep "something" > /var/log/logfile2

but this way i have same lines both in logfile and logfile2, which
consumes hard drive (logfile can be really large. up to 5 GB after 1 week).

i'm afraid of deleting anything from file while syslogd writes to it. i
can't lost any single line which comes to it. so i thougth about writing
  program, which would be working between syslogd and filesystem, read
output from syslogd and writes it to appropriate file. syslogd would
write to pipe-file and my program would read from that pipe. is it maybe
easiest way to do it?


Serwis Usenet w portalu ->

2. ACK filtering in TCP

3. kmail 1.3.2 filters: Howto filter all messages?

4. lpd help anyone?

5. Simple question about message filter

6. no sucsessfull start after succsessfull installation

7. (Filtering || Shell script) question

8. Mysterious Buslogic/SCSI Disk Problem

9. using logger write message twice to messages file

10. Solaris 2.5.1: Does the kernel buffer up messages b4 writing to /var/adm/messages

11. Filters, Filters, where are you Filters...

12. Simple Script Writing Question

13. Question: writing or getting hold of a dial-up script