procmail
[Top] [All Lists]

Re: nul detection

1997-12-05 00:06:54
Thu 97-12-04 Rik Kabel <rik(_at_)netcom(_dot_)com> list.procmail
| 
| I have been trying to formulate a recipe which catches a nul, and have
| not been successful. I can catch bel, but similar tests fail for nul.
|
|  SHELL=/bin/sh
|  NUL=`/usr/5bin/echo "\000"`
|  BEL=`/usr/5bin/echo "\007"`

Dan got me thinking about the process size and the expence of calling
many shell commands. I realized that grep/sed is _twice_ as big binary as
what awk is. Funny, awk is much more powerfull. Why would I now use
sed/grep any more?

Have anyone looked at the binary sizes lately :-) I'm a real perl
lower, but now I understand why I should use it with great care from
inside procmail.

-r-xr-xr-x   1 bin        bin         131072 Aug 21  1996 /usr/bin/awk
-r-xr-xr-x   3 bin        bin         245760 Jun 10  1996 /usr/bin/grep
-r-xr-xr-x   1 bin        bin         262144 Jun 10  1996 /usr/bin/sed
-r-xr-xr-x   1 bin        bin         544768 Jun 10  1996 /usr/contrib/bin/perl
-rwxr-xr-x   1 root       nms         822232 Aug 25 13:58 
/opt/local/bin/perl5.00401

That was only the introduction :-) 

If you want to catch a NULL only _once_, then an awk would be easy.
If you want to catch it many times in different recipes, then
saving the value to a procmail variables is best, as you just
showed. (I don't know solution for that).

    #   EXIT_SUCCESS  (=0)
    :0 b    
    * ? awk '{if (/\000/){exit 0}else{exit 1}}' 
    {
        # Yay, it had null in the message. Is this bozo sending binary to me?
    }

jari



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