Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to execute a sendmail alias script using this

# aliases for my system
addressx:        |sh /usr/share/scripts/myscript.sh  WON'T WORK
addressx:        '/usr/share/scripts/myscript.sh'  WON'T WORK
addressx:        '|/usr/share/scripts/myscripts.sh'  WON'T WORK

Can I execute scripts or it must be a binary file ?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Sendmail uses a restricted shell to execute. You have to put programs that Sendmail can execute in the /etc/smrsh directory. You can find out more about this here.

You should of course also ensure that the execute bit is set appropriately on that script, and that it is world readable (but not world writable).

share|improve this answer
    
worked perfectly. Shit! never saw such a complicated config file like the sendmail.cf thanks –  Rodrigo Asensio May 4 '10 at 18:46
add comment

The P= equate shows which shell is used to execute piped delivery. This is typically either /usr/bin/smrsh or /bin/sh. You should use whichever one meets your needs. /bin/sh is less persnickety but is less secure. /usr/bin/smrsh is more secure but has rules.

You don't need to do something like |sh myscript.sh, the shell is identified in the sendmail configuration.

You can execute scripts as well as binary files, BTW.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.