added plain file mode to convkeps and also made it an update
authordjk <djk>
Fri, 10 Mar 2000 21:42:01 +0000 (21:42 +0000)
committerdjk <djk>
Fri, 10 Mar 2000 21:42:01 +0000 (21:42 +0000)
perl/Keps.pm
perl/convkeps.pl

index 4a0596253907d3db702f227887f7c20f4c45b4f2..657793b21e9e90fa260f5dcb6a3119a6a8cf12bc 100644 (file)
@@ -1,6 +1,8 @@
 #
 # this file is automatically produced by convkeps.pl
 #
+# Last update: Fri Mar 10 21:40:03 2000
+#
 
 package Sun;
 
index 5102e3d22c65d6071f23294f7d181e10a9b468ae..3b08e64db62c2a8997a2f8873812cb74983fedd1 100755 (executable)
@@ -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
 #
 # 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)
+# 
 # Copyright (c) 2000 Dirk Koopman G1TLH
 #
 # $Id$
 #
 
 require 5.004;
+package Sun;
 
 # search local then perl directories
 BEGIN {
@@ -38,18 +46,32 @@ BEGIN {
 }
 
 use strict;
-use Data::Dumper;
+use vars qw($root %keps);
 
-use vars qw($root);
+use Data::Dumper;
+use Keps;
 
 my $fn = "$root/local/Keps.pm";
 my $state = 0;
 my $name;
-my %keps;
 my $ref;
 my $line;
+my $f = \*STDIN;
 
-while (<STDIN>) {
+while (@ARGV) {
+       my $arg = shift @ARGV;
+       if ($arg eq '-p') {
+               $state = 1;
+       } elsif ($arg eq '-e') {
+               $state = 0;
+       } elsif ($arg =~ /^-/) {
+               die "Usage: convkeps.pl [-e|-p] [<filename>]\n\t-p - plain file just containing keps\n\t-e - amsat email format input file (default)\n";
+       } else {
+               open (IN, $arg) or die "cannot open $arg (!$)";
+               $f = \*IN;
+       }
+}
+while (<$f>) {
        ++$line;
        chomp;
        s/^\s+//;
@@ -113,6 +135,7 @@ $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";