procmail
[Top] [All Lists]

Re: Script won't Run

2000-08-24 08:05:47
Ken Young has problems with this recipe:

| :0 c:script.lock
| * BH ?? ://
| | ~/script/hello.bat

It gives this error in his logfile:

| stty: : Invalid argument
| TERM: Undefined variable.

PROBLEM #1:

When procmail sees a tilde or any other character from $SHELLMETAS in an
action line, it invokes a shell to run the command instead of trying to run
it itself.  Apparently your login shell is csh or a csh-derivative, so when
procmail invokes your shell, it tries to run your .cshrc, and you have
terminal-dependent code in there such as an stty command, which belongs in
your .login instead; or if it must be in your .cshrc, it should be wrapped
in an if-endif structure that runs it only if the process is attached to a
terminal.

csh and its derivatives are not good for scripting, only for interactive
shell sessions (and you'll get arguments that they aren't good for those
either).  

There are a number of ways to fix it.  The most comprehensive is to fumigate
your rcfile and get the csh out of it.  Put

 SHELL=/bin/sh

at the top of your rcfile; then use "$HOME" instead of a tilde, since sh does
not grok tildes but it does understand the $HOME variable.

PROBLEM #2:

Standard output from commands in a procmail rcfile usually goes nowhere
(there are exceptions).  If hello.bat echoes "Hello world!" to standard
output, you won't find it on your screen nor in your mailbox.  You can
change hello.bat (or the action line of the recipe) [a] to echo the words to
standard error, and if you have a LOGFILE defined you'll find them there
(though usually it's better to insert text into procmail's logfile by using
the LOG variable), or [b] to redirect echo to another file (preferably by
appending, so that if you run the test several times, you can tell whether
there is yet another line of "Hello world!" in it or not).


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>