[pskmail] How to generate info files for the server

  • From: Rein Couperus <rein@xxxxxxxxxxxx>
  • To: pskmail@xxxxxxxxxxxxx
  • Date: Mon, 18 Aug 2008 20:55:54 +0200

The file area at the pskmail server is located in ~/.pskmail/pskdownloads

Here is EU we are providing e.g. fresh WX info for sailors. The internet is an 
infinitive source of information. One problem is that most web pages rely on 
pictures rather than text. And we have to consider the bandwidth of the 
pskmail system.

Filtering out the important text bits is best done with a perl script.
An example which extracts the text information from web pages on the 
gmdss site is attached. It uses elinks to kill the pictures, and filters out 
those portions of the text we need. The generated text file is then copied 
to ~/.pskmail/pskdownloads, from where it can be listed, downloaded or 
updated (refreshed) by the client.

I also use a script on PI4TUE to exract Navtex information.

Attached the script gmdss.pl, which extracts weather data an storm warnings 
for METAREA_I, the NE atlantic area. You may be able to use it as 
an example how to make one for your area.... I run it with a cron job every 4 
hours 
to keep the files updated with the latest WX.

73,

Rein PA0R

-- 
http://pa0r.blogspirit.com
#! /usr/bin/perl -w

my $printflg = 0;
my $debug = 0;

if ($debug) {print "Gmdss download starting\n";}

@site = `elinks -dump  http://weather.gmdss.org/I.html`;

foreach $webline (@site) {
        if ($webline =~ /\d+\.(.*WARNING.*)\.html/) {
                my @content = `elinks -dump "$1.html"`;
                open (CONTENT, 
">$ENV{HOME}/.pskmail/pskdownload/METAREA_I_WARNING");
                
                print CONTENT "METAREA_I_WARNING  - ", `date -u`, "\n";
                
                foreach my $line (@content) {
# print $line;
                        if ($line =~ /\-\-\-/) {
                                $printflg = 1;
                        } elsif ($line =~ /References/) {
                                $printflg = 0;
                        } else {
                                if ($debug) {print $line unless $printflg == 0;}
                                print CONTENT $line unless $printflg == 0;
                        }
                }
                close (CONTENT);
                `cat $ENV{HOME}/.pskmail/pskdownload/METAREA_I_WARNING >> 
gmdss.log`;
                        
        } elsif ($webline =~ /\d+\.(.*HIGH_SEAS_FORECAST.*)\.html/) {
                my @content = `elinks -dump "$1.html"`;
                open (CONTENT, 
">$ENV{HOME}/.pskmail/pskdownload/METAREA_I_HIGH_SEAS_FORECAST");

                print CONTENT "METAREA_I_HIGH_SEAS_FORECAST  - ", `date -u`, 
"\n";


                foreach my $line (@content) {
                        if ($line =~ /\-\-\-/) {
                                $printflg = 1;
                        } elsif ($line =~ /References/) {
                                $printflg = 0;
                        } else {
                                if ($debug) {print $line unless $printflg == 0;}
                                print CONTENT $line unless $printflg == 0;
                        }
                }
                close (CONTENT);
                 `cat 
$ENV{HOME}/.pskmail/pskdownload/METAREA_I_HIGH_SEAS_FORECAST >> gmdss.log`;

        } elsif ($webline =~ /\d+\.(.*OFF_SHORE_FORECAST.*)\.html/) {
                my @content = `elinks -dump "$1.html"`;
                open (CONTENT, 
">$ENV{HOME}/.pskmail/pskdownload/METAREA_I_OFF_SHORE_FORECAST");
 
                print CONTENT "METAREA_I_OFF_SHORE_FORECAST  - ", `date -u`, 
"\n";

 
                foreach my $line (@content) {
                        if ($line =~ /\-\-\-/) {
                                $printflg = 1;
                        } elsif ($line =~ /References/) {
                                $printflg = 0;
                        } else {
                                if ($debug) {print $line unless $printflg == 0;}
                                print CONTENT $line unless $printflg == 0;
                        }
                }
                close (CONTENT);
                 `cat 
$ENV{HOME}/.pskmail/pskdownload/METAREA_I_OFF_SHORE_FORECAST >> gmdss.log`;
        }
} 

Other related posts: