Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple example of using an alias to execute a local program

41 views
Skip to first unread message

Joe Guidera [MS-MVP/ClubWin]

unread,
Jul 27, 2000, 3:00:00 AM7/27/00
to
I know this should be simple, but for my life I can't seem to get it to
work. Can anyone provide a simple example of an alias entry and
corresponding dummy script that will cause mail addressed to a local alias
to execute said script?

For example:

I've tried something like

mycmd: |/usr/adm/sm.bin/doit

In aliases, executed newalias to add the alias to the compiled db
then created a simple script (perms 755) in /usr/adm/sm.bin called "doit"
that simply has:

#!/bin/ksh
echo $* > /tmp/doit.log


When I try to send mail to the alias it bounces with:

smrsh: doit not available for sendmail programs
554 5.0.0 |/usr/adm/sm.bin/doit... Service Unavailable


Any thoughts?

--
--------------------------------
Joe Guidera
jgui...@msn.com


G. Roderick Singleton

unread,
Jul 27, 2000, 3:00:00 AM7/27/00
to


YES! Read the FAQ. I'll give you a hint
http://www.sendmail.org/faq/section3.html#3.11
--
________________________________________________________________________________
G. Roderick Singleton, <gsing...@home.com> PATH tech,
71 Underhill Drive, Unit 159, Toronto, ON M3A 2J8
Voice : 416-452-4583 Fax: 416-452-0036 Toll Free: 1-888-354-PATH
________________________________________________________________________________

*** Notice To Bulk Emailers: Attention! Pursuant to US Code, Title 47,
Chapter 5, Subchapter II, 227, any & all unsolicited commercial e-mail
sent to this address is subject to a download and archival fee in the
amount of the $1500 US and copies will be forwarded to domain
administrators. Emailing denotes acceptance of said terms!

Jamie Jackson

unread,
Jul 27, 2000, 3:00:00 AM7/27/00
to
"G. Roderick Singleton" wrote:

>
> "Joe Guidera [MS-MVP/ClubWin]" wrote:
> > smrsh: doit not available for sendmail programs
> > 554 5.0.0 |/usr/adm/sm.bin/doit... Service Unavailable
> >
> > Any thoughts?
> >
>
> YES! Read the FAQ. I'll give you a hint
> http://www.sendmail.org/faq/section3.html#3.11
> --

I have a similar problem and have read the advise in the FAQ you quoted
and have included /SENDMAIL/ANY/SHELL/ in /etc/shells. I get the same
error message.

I am try to run a simple perl script that just reads the message from
STDIN and mails it to an address. The script looks like this:

#!/usr/bin/perl -w

use Mail::Send;


my $msg = new Mail::Send Subject=>'Perl Alias Test',
To=>'jamie....@marconi.com';

my $fh = $msg->open;

while (<STDIN>) {
print $fh $_;
}

$fh->close;

Simple enough eh? This works fine from the command line.

This script is installed in /usr/local/bin with the following
permissions:

-rwsr-xr-x 1 root root 245 Jul 27 13:52 aliastest.pl

My /etc/aliases file has an entry like this:

gkirdb: "|/usr/local/bin/aliastest.pl"

When I send a mail to this alias the send mail log gets an entry like
this:

Jul 27 14:52:15 cvup1100 sendmail[2969]: OAA02969: from=<XXXXXX>,
size=2795, class=0, pri=32795, nrcpts=1,
msgid=<C1256929.0...@marconicomms.com>, proto=ESMTP,
relay=cvsf325.gpt.co.uk [89.1.21.77]
Jul 27 14:52:15 cvup1100 smrsh: uid 8: attempt to use aliastest.pl
Jul 27 14:52:15 cvup1100 sendmail[2970]: OAA02969:
to="|/usr/local/bin/aliastest.pl", delay=00:00:00, xdelay=00:00:00,
mailer=prog, stat=Service unavailable
Jul 27 14:52:15 cvup1100 sendmail[2970]: OAA02969: OAA02970: DSN:
Service unavailable
Jul 27 14:52:59 cvup1100 sendmail[2970]: OAA02970: to=<XXXXXX>,
delay=00:00:44, xdelay=00:00:44, mailer=relay, relay=cvis01.gpt.co.uk.
[195.99.244.34], stat=Sent (OAA23664 Message accepted for delivery)


Hope someone can help us both.

Regards
Jamie Jackson

G. Roderick Singleton

unread,
Jul 27, 2000, 3:00:00 AM7/27/00
to

I see you didn't follow all the links. Please do so.

Joe Guidera

unread,
Jul 28, 2000, 3:00:00 AM7/28/00
to
Cheers,

I quite carefully followed all of the links (both before I posted and yet
again now). While it's entirely possible that I missed something obvious,
I'd be appreciative if anyone has any further direction...

I removed the feature smrsh (thinking it might have been a problem there)
from my config and rebuilt my sendmail.cf. Don't think I mentioned before
but "mycmd" is not an actual user, so this is runnning out of the global
alias file instead of a users' .forward file (is that a problem? Does
"mycmd" need to be a real user?).

Now I get the following from sendmail:

--------------------------------------
snip --------------------------------------
|/usr/adm/sm.bin/doit
(reason: 126)
(expanded from: mycmd)

----- Transcript of session follows -----
sh: /usr/adm/sm.bin/doit: not found
554 5.3.0 |/usr/adm/sm.bin/doit... unknown mailer error 126

Final-Recipient: RFC822; mycmd
X-Actual-Recipient: X-Unix; |/usr/adm/sm.bin/doit
Action: failed
Status: 5.0.0
Diagnostic-Code: X-Unix; 126
--------------------------------------
snip --------------------------------------

I also made sure to create an /etc/shells file and populated it with a
shell= including the /SENDMAIL line shown in the FAQ.


--
--------------------------------
Joe Guidera
jgui...@msn.com

"G. Roderick Singleton" <gsing...@home.com> wrote in message
news:39805302...@home.com...

G. Roderick Singleton

unread,
Jul 28, 2000, 3:00:00 AM7/28/00
to
1) Please ensure you have Mailtools module installed.
2) Your script should probably look like this:

#!/usr/bin/perl -w

require Mail::Send;

$msg = new Mail::Send Subject=>'Perl Alias Test',
To=>'jamie....@marconi.com';

$fh = $msg->open;

while (<STDIN>) {
print $fh $_;
}

$fh->close;

3) Once it works put back the 'my's
4) Ask Jamie if he received my tests.
--
________________________________________________________________________________

0 new messages