From: minima Date: Fri, 24 Sep 2004 13:09:30 +0000 (+0000) Subject: add import keps for incoming keps email messages X-Git-Tag: 1.53~223 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=8216591f8355cc88b277c25a854527408bce8a3d;p=spider.git add import keps for incoming keps email messages --- diff --git a/perl/importkeps.pl b/perl/importkeps.pl new file mode 100644 index 00000000..42787167 --- /dev/null +++ b/perl/importkeps.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl +# +# Take a 2 line keps email file on STDIN, prepare it for import into standard import directory +# and then shove it there, marked for SB ALL. +# +# Copyright (c) Dirk Koopman G1TLH +# +# $Id$ +# + +use strict; + +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 $inp; +{ + local $/ = undef; + $inp = ; +} + +# is it a 2 line kep file? +if ($inp =~ /ubject:\s+\[keps\]\s+orb\d{5}\.2l\.amsat/) { + process(); +} + +exit(0); + + +# +# process the file +# + +sub process +{ + # chop off most of the beginning + return unless $inp =~ s/^.*SB\s+KEPS\s+\@\s+AMSAT\s+\$ORB\d{5}\.\w/SB ALL/s; + return unless $inp =~ s/2Line\s+Orbital\s+Elements/2Line Keps/; + + # open the output file in the data area + my $fn = "$root/data/keps.txt.$$"; + open OUT, ">$fn" or die "$fn $!"; + print OUT $inp; + close OUT; + + link $fn, "$root/msg/import/keps.txt.$$"; + unlink $fn; +}