X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fconvkeps.pl;h=268a7f29f7ea58a1ce3ba326a37125e4297e9bde;hb=4e6ea4e7991cf205a61637e16f5cf852399e7ad9;hp=5102e3d22c65d6071f23294f7d181e10a9b468ae;hpb=9cac31473878fc88778cb13d843fa77c5fd33d65;p=spider.git diff --git a/perl/convkeps.pl b/perl/convkeps.pl index 5102e3d2..268a7f29 100755 --- a/perl/convkeps.pl +++ b/perl/convkeps.pl @@ -8,7 +8,8 @@ # It will write a file called /spider/local/Keps.pm, this means that # the latest version will be read in every time you restart the # cluster.pl. You can also call Sun::load from a cron line if -# you like to re-read it automatically. +# you like to re-read it automatically. If you update it manually +# load/keps will load the latest version into the cluster # # This program is designed to be called from /etc/aliases or # a .forward file so you can get yourself on the keps mailing @@ -20,12 +21,22 @@ # # http://www.amsat.org/amsat/ftp/keps/current/nasa.all # +# Please note that this will UPDATE your keps file +# +# Usage: +# email | convkeps.pl (in amsat email format) +# convkeps.pl -p keps.in (a file with just plain keps) +# +# if you add the -c flag then the %keps hash will be cleared down +# before adding the new ones. +# # Copyright (c) 2000 Dirk Koopman G1TLH # # $Id$ # require 5.004; +package Sun; # search local then perl directories BEGIN { @@ -38,22 +49,39 @@ BEGIN { } use strict; -use Data::Dumper; +use vars qw($root %keps); -use vars qw($root); +use Data::Dumper; +require Keps; my $fn = "$root/local/Keps.pm"; my $state = 0; my $name; -my %keps; my $ref; my $line; +my $f = \*STDIN; + +while (@ARGV) { + my $arg = shift @ARGV; + if ($arg eq '-p') { + $state = 1; + } elsif ($arg eq '-e') { + $state = 0; + } elsif ($arg eq '-c') { + %keps = (); + } elsif ($arg =~ /^-/) { + die "Usage: convkeps.pl [-c] [-e|-p] []\n\t-p - plain file just containing keps\n\t-e - amsat email format input file (default)\n\t-c - clear Keps data before adding this lot\n"; + } else { + open (IN, $arg) or die "cannot open $arg (!$)"; + $f = \*IN; + } +} -while () { +while (<$f>) { ++$line; chomp; s/^\s+//; - s/\s+$//; + s/[\s\r]+$//; next unless $_; last if m{^/EX}i; last if m{^-}; @@ -65,7 +93,7 @@ while () { if (/^\w+/) { s/\s/-/g; - $name = $_; + $name = uc $_; $ref = $keps{$name} = {}; $state = 2; } @@ -79,8 +107,8 @@ while () { $ref->{mm2} = genenum($mm2); $ref->{bstar} = genenum($bstar); $ref->{elset} = $elset - 0; -# print "$id $number $epoch $decay $mm2 $bstar $elset\n"; -# print "mm2: $ref->{mm2} bstar: $ref->{bstar}\n"; + #print "$id $number $epoch $decay $mm2 $bstar $elset\n"; + #print "mm2: $ref->{mm2} bstar: $ref->{bstar}\n"; $state = 3; } else { @@ -113,9 +141,10 @@ $dd->Indent(1); $dd->Quotekeys(0); open(OUT, ">$fn") or die "$fn $!"; print OUT "#\n# this file is automatically produced by convkeps.pl\n#\n"; +print OUT "# Last update: ", scalar gmtime, "\n#\n"; print OUT "\npackage Sun;\n\n"; print OUT $dd->Dumpxs; -print OUT "\n"; +print OUT "1;\n"; close(OUT); @@ -123,6 +152,7 @@ close(OUT); sub genenum { my ($sign, $frac, $esign, $exp) = unpack "aa5aa", shift; + $esign = '+' if $esign eq ' '; my $n = $sign . "." . $frac . 'e' . $esign . $exp; return $n - 0; }