#!/usr/bin/perl -w # 24jul2003 kci -- get wx obs from Anch NWS cgi url use strict; my $url = "http://pafc.arh.noaa.gov/obs.php"; my $sta = shift; die qq(usage: \$ $0 [--list] [--help] STATION [HOURS]\n) unless $sta; system("pod2text $0") && exit if $sta eq '--help'; my $hours = shift || 3; if ( $sta eq '--list' ) { # get and display station list my $getsta; foreach ( `/usr/bin/wget -O- '$url' 2>/dev/null` ) { $getsta = 1 if m/Select Station:/; $getsta = 0 if m||; next unless $getsta; chomp; next unless m|value="([^"]+)">(.*)|; my ($id, $name) = ($1, $2); print "$id\t$name\n"; } exit 0; } my $pre; foreach ( `/usr/bin/wget -O- '$url?stnid=$sta\&phours=$hours' 2>/dev/null` ) { if ( !$pre && m/ : / ) { # station id header my ($stnhdr) = m|(.*)|; print "$stnhdr\n"; } $pre = 0 if m||; print $_ if $pre && !m/^$/; $pre = 1 if m|
|;
    }

#PAQT  AP 24 2026Z FEW007 BKN011 OVC020      10 R-       57  55 26014     961  93%  57    
#current UTC 
my @gmt = gmtime();
my $tz = (localtime())[-1] ? 'AKDT' : 'AKST';
my @loc = localtime();
my $host = `hostname`;
chomp $host;

print "            $gmt[2]$gmt[1]Z UTC -- current time ", 
      scalar localtime(), 
      " $tz on host $host\n";


=head1 NAME

wxobs -- grab current weather observations

=head1 SYNOPSIS

    $ wxobs STATION

where STATION is a valid (supported) station identier tag for Alaska, for
example PABI (Delta Junction). 

=head1 OPTIONS

=over

=item --list

display list of stations & ids

=item --help

display (this) help message

=back

(Actually, these "options" are mutually exclusive.)