X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fprocess_ursa.pl;h=9196169f9a8efdae19b04d595c1d01cd01311e1b;hb=refs%2Fheads%2Fnewdisc;hp=42b5a36054097874e0da0295aa8bfb96ec1173f8;hpb=39cc57add0d181ac15f470ddfe47ffc5ea8accd1;p=spider.git diff --git a/perl/process_ursa.pl b/perl/process_ursa.pl index 42b5a360..9196169f 100644 --- a/perl/process_ursa.pl +++ b/perl/process_ursa.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Process and import for mail SIDC Ursagrams # @@ -6,19 +6,33 @@ # and, if it is an URSIGRAM, imports it into the local # spider msg queue. # -# Copyright (c) Dirk Koopman G1TLH +# Copyright (c) 2004 Dirk Koopman G1TLH +# # -# $Id$ # use strict; use Mail::Internet; use Mail::Header; -my $import = '/spider/msg/import'; +our $root; + +# search local then perl directories +BEGIN { + # root of directory tree for this system + $root = "/spider"; + $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'}; + + unshift @INC, "$root/perl"; # this IS the right way round! + unshift @INC, "$root/local"; +} + +my $import = "$root/msg/import"; +my $tmp = "$root/tmp"; my $msg = Mail::Internet->new(\*STDIN) or die "Mail::Internet $!"; my $head = $msg->head->header_hashref; +my $fromcall = shift || 'G1TLH'; if ($head && $head->{From}->[0] =~ /sidc/i && $head->{Subject}->[0] =~ /Ursigram/i) { my $body = $msg->body; @@ -31,11 +45,14 @@ if ($head && $head->{From}->[0] =~ /sidc/i && $head->{Subject}->[0] =~ /Ursigram last; } } - open OUT, ">$import/ursigram$date.txt" or die "import $!"; - print OUT "SB ALL\n$title\n"; + my $fn = "ursigram$date.txt.$$"; + open OUT, ">$tmp/$fn" or die "import $tmp/$fn $!"; + print OUT "SB ALL < $fromcall\n$title\n"; print OUT map {s/\r\n$/\n/; $_} @$body; print OUT "/ex\n"; close OUT; + link "$tmp/$fn", "$import/$fn"; + unlink "$tmp/$fn"; } exit(0);