On Fri, Oct 2, 2009 at 7:02 AM, Rod Whitworth <glis...@witworx.com> wrote:
> On Thu, 01 Oct 2009 09:36:24 -0400, Frank Bax wrote:
>
>>Rod Whitworth wrote:
>>> nixpix:
>>> #!/bin/sh
>>> cd /root/data
>>> rm -f nixspam
>>> ftp http://www.openbsd.org/spamd/nixspam.gz
>>> if [ $? -eq 0 ] ; then
>>>         gunzip nixspam.gz
>>>         cut -d " " -f 1 nixspam >/var/db/nixspam
>>> fi
>>
>>
>>Any particular reason why you don't use:
>>       zcat nixspam.gz | cut -d " " -f 1 > /var/db/nixspam
>
> I was gunzip-ing it for inspection so I was lazy and used the already
> unzipped file.
> Then I had to add the guzip line to this script anyway. But you know
> how these things happen late at night...
>>
>>Obviously the above script must run before spamd-setup; how much sooner
>>do you run it?
>
> 6 minutes.
>>
>
> *** NOTE *** Please DO NOT CC me. I <am> subscribed to the list.
> Mail to the sender address that does not originate at the list server is
tarpitted. The reply-to: address is provided for those who feel compelled to
reply off list. Thankyou.
>
> Rod/
> ---
> This life is not the real thing.
> It is not even in Beta.
> If it was, then OpenBSD would already have a man page for it.
>
>

That would probably cause issues if the gunzip operation failed -
you'd end up with an empty nixspam file.  I'd do the same but check
the return value of the gunzip operation before overwriting the
nixspam file.  I'd also streamline the script a bit:

#!/bin/sh
cd /root/data
rm -f nixspam
if ftp http://www.openbsd.org/spamd/nixspam.gz; then
        if gunzip nixspam.gz; then
                cut -d ' ' -f 1 nixspam > /var/db/nixspam
        fi
fi

Diff:
--- nixpix.orig Fri Oct  2 14:27:14 2009
+++ nixpix      Fri Oct  2 14:27:10 2009
@@ -1,9 +1,9 @@
 #!/bin/sh
 cd /root/data
 rm -f nixspam
-ftp http://www.openbsd.org/spamd/nixspam.gz
-if [ $? -eq 0 ] ; then
-       gunzip nixspam.gz
-       cut -d " " -f 1 nixspam >/var/db/nixspam
+if ftp http://www.openbsd.org/spamd/nixspam.gz; then
+       if gunzip nixspam.gz; then
+              cut -d ' ' -f 1 nixspam > /var/db/nixspam
+       fi
 fi
 exit

I'd test this on something you don't care about first, just to be sure.

--
Aaron Mason - Programmer, open source addict
- Oh, why does everything I whip leave me?

Reply via email to