mail filter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mail filter
# 1  
Old 01-24-2002
mail filter

Hi all:

I have a problem with this simple script. It appears that it should work, but I am getting an error message.

I am trying to pass a file through a filter to grep for "urgent" and forward the message to me.

Here it is.

#!/bin/ksh
#
if (`grep urgent /tmp/test.tmp| wc -l` -gt 0)
then
mailx -s "urgent message" root < /tmp/test.tmp
else
mailx -s "mail forwarded from sysname" tm6858 < /tmp/test.tmp
fi



My error message is this:

root> ./urgent.sh
./urgent.sh[3]: 2: not found

Smilie
# 2  
Old 01-24-2002
sendmail errors

I got this message as a response to the program.

What does "not available for sendmail programs" mean?


The original message was received at Thu, 24 Jan 2002 07:28:50 -0600 (CST)
from root@localhost

----- The following addresses had permanent fatal errors -----
"|/root/urgent.sh"
(expanded from: userID)

----- Transcript of session follows -----
sh: urgent.sh not available for sendmail programs
554 "|/root/urgent.sh" ... Service unavailable



Here is my /etc/aliases output.

userID :"|/root/urgent.sh"


Smilie
# 3  
Old 01-24-2002
You set this up as ksh but are using ( ) in your if statement.

Remember to put in the white space.

if [ `grep urgent /tmp/test.tmp| wc -l` -gt 0 ]
thehoghunter
# 4  
Old 01-24-2002
Thanks I forgot about the whitespace. That did solve the first problem.

However, I am still getting this error message.

----- The following addresses had permanent fatal errors -----
"|/root/urgent.sh"
(expanded from: tm6858)

----- Transcript of session follows -----
sh: urgent.sh not available for sendmail programs
554 "|/root/urgent.sh" ... Service unavailable
# 5  
Old 01-24-2002
How are you running this? Are you setting this as part of a forward file? (The script by itself will work.)
thehoghunter
# 6  
Old 01-24-2002
I have a file in the /tmp directory called /tmp/test.tmp

I mail this file to a user who is aliased in the /etc/aliases file.
tm6858 :"|/root/urgent.sh"

This file is owned by root...
-rwxr-xr-x 1 root sys 196 Jan 24 08:28 urgent.sh


I have this script process the file and forward it to root if it is "urgent" or if not it just sends the file to the user.
# 7  
Old 01-24-2002
What version of Sendmail ?

I tried it and it worked fine after I set up the alias and did the newaliases command (I called the script test2)

/etc/mail/aliases:
hog: "|/tmp/test2"

The only thing I can think of is that Sendmail won't use a script if it's set up as the 'shell' for an account - it will complain if it's not in /etc/shells. See the FAQ on www.sendmail.org.
thehoghunter
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. UNIX for Dummies Questions & Answers

Filter records in a huge text file from a filter text file

Hi Folks, I have a text file with lots of rows with duplicates in the first column, i want to filter out records based on filter columns in a different filter text file. bash scripting is what i need. Data.txt Name OrderID Quantity Sam 123 300 Jay 342 498 Kev 78 2500 Sam 420 50 Vic 10... (3 Replies)
Discussion started by: tech_frk
3 Replies

3. Linux

awk filter & Auto gen Mail

hi experts 2012-01-30 10:30:01:812 "y" "NA" "30/01/2012 10:30:01:154 AM" 2012-01-30 10:33:46:342 "y" "NA" "30/01/2012 10:33:45:752 AM" 2012-01-30 10:41:11:148 "n" "200" "30/01/2012 10:41:10:558 AM" 2012-01-30 10:44:48:049 "y" "NA" ... (7 Replies)
Discussion started by: nith_anandan
7 Replies

4. OS X (Apple)

Why are the subjects of deleted mail messages still in Mail Viewing pane?

I was wondering -- when I delete a mail message, I know it goes into the trash, but I've noticed that the subject lines of messages are still in the viewing pane, and I have to delete them as well. Can anyone tell me why this is, and where they are? (1 Reply)
Discussion started by: Straitsfan
1 Replies

5. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

6. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

7. Solaris

how to forward mail in /var/mail/username to external mail

Dear All, Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do? thank u in advance (2 Replies)
Discussion started by: unitipon
2 Replies

8. UNIX for Advanced & Expert Users

Mail Filter

hai friends. How can i filter the incoming mails to an individual folder.. I am using sendmail. Thanks in advance Collins (4 Replies)
Discussion started by: collins
4 Replies

9. UNIX for Dummies Questions & Answers

mail problem (NOT Mail or Mail.app)

When I try to use the CLI mail, I get the following error. What's wrong? Welcome to Darwin! % mail root Subject: test test . EOT % /etc/mail/sendmail.cf: line 81: fileclass: cannot open /etc/mail/local-host-names: Group writable directory Do I just need to change the... (1 Reply)
Discussion started by: chenly
1 Replies
Login or Register to Ask a Question