From: minima Date: Wed, 4 Aug 2004 13:12:48 +0000 (+0000) Subject: add ursigram processor X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fremotes%2Fserver%2FNewRoute;p=spider.git add ursigram processor --- diff --git a/perl/process_ursa.pl b/perl/process_ursa.pl new file mode 100644 index 00000000..42b5a360 --- /dev/null +++ b/perl/process_ursa.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl +# +# Process and import for mail SIDC Ursagrams +# +# This program takes a mail message on its standard input +# and, if it is an URSIGRAM, imports it into the local +# spider msg queue. +# +# Copyright (c) Dirk Koopman G1TLH +# +# $Id$ +# + +use strict; +use Mail::Internet; +use Mail::Header; + +my $import = '/spider/msg/import'; + +my $msg = Mail::Internet->new(\*STDIN) or die "Mail::Internet $!"; +my $head = $msg->head->header_hashref; + +if ($head && $head->{From}->[0] =~ /sidc/i && $head->{Subject}->[0] =~ /Ursigram/i) { + my $body = $msg->body; + my $title = 'SIDC Ursigram'; + my $date = ''; + foreach my $l (@$body) { + if ($l =~ /SIDC\s+SOLAR\s+BULLETIN\s+(\d+)\s+(\w+)\s+20(\d\d)/) { + $date = "$1$2$3"; + $title .= " $date"; + last; + } + } + open OUT, ">$import/ursigram$date.txt" or die "import $!"; + print OUT "SB ALL\n$title\n"; + print OUT map {s/\r\n$/\n/; $_} @$body; + print OUT "/ex\n"; + close OUT; +} + +exit(0);