add DXCIDR, fix version no tracking
[spider.git] / perl / importwwv.pl
index bca63688e28751f68dd1817f42524787f8bd126d..f0fcfec0d651d093e7563e009144105bbbeee0e8 100755 (executable)
@@ -11,7 +11,7 @@
 #
 # Copyright (c) 2004 Dirk Koopman G1TLH
 #
-# $Id$
+#
 #
 
 use strict;
@@ -37,7 +37,7 @@ my $msg = Mail::Internet->new(\*STDIN) or die "Mail::Internet $!";
 my $head = $msg->head->header_hashref;
 
 if ($head) {
-       if ($head->{From}->[0] =~ /wwv/i || $head->{'From '}->[0] =~ /wwv/i) {
+       if ($head->{Subject}->[0] =~ /wwv/i) {
                process_wwv($msg);
        } elsif ($head->{From}->[0] =~ /rwc\.boulder/i || $head->{'From '}->[0] =~ /rwc\.boulder/i) {
                process_solar($msg);
@@ -62,6 +62,7 @@ sub process_wwv
                }
                if ($state) {
                        my $l = $_;
+                       next if /\bSec\b/i;
                        $l =~ s/\s*\.?\r?\n$//;
                        push @out, $l;
                }
@@ -87,6 +88,7 @@ sub process_solar
                }
                if ($state > 1) {
                        my $l = $_;
+                       next if /\bSec\b/i;
                        $l =~ s/\r?\n$//;
                        push @out, $l;
                }
@@ -99,8 +101,13 @@ sub out
        my $fn = "solar.txt.$$";
    
        open OUT, ">$tmp/$fn" or die "import $tmp/$fn $!";
+       chmod 0666, "$tmp/$fn";
        print OUT map { "$_\n" } @_;
        close OUT;
+
+       # Note we do this this way to make the appearance of
+       # the file in /spider/chat_import atomic. Otherwise there
+       # exists the possiblity of race conditions and other nasties
        link "$tmp/$fn", "$import/$fn";
        unlink "$tmp/$fn";
 }