2020-01-21 14:01:04 -07:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use JSON;
|
|
|
|
|
2023-02-10 10:54:10 -07:00
|
|
|
my $URL_lat = $ARGV[0] or scalar(40.4936);
|
|
|
|
my $URL_lon = $ARGV[1] or scalar(-111.9388);
|
2020-01-21 14:01:04 -07:00
|
|
|
|
2020-01-21 15:10:25 -07:00
|
|
|
my $info = `curl -sm 5 "https://forecast.weather.gov/MapClick.php?lat=$URL_lat&lon=$URL_lon&unit=0&lg=english&FcstType=json"` or die "Error";
|
2020-01-21 14:01:04 -07:00
|
|
|
|
|
|
|
my $json = decode_json $info or die "Error";
|
|
|
|
|
2020-07-21 10:17:29 -06:00
|
|
|
my $loc = %{$json}{"location"}->{"areaDescription"};
|
2020-01-21 14:01:04 -07:00
|
|
|
my $temp = %{$json}{"currentobservation"}->{"Temp"};
|
|
|
|
my $windS = %{$json}{"currentobservation"}->{"Winds"};
|
|
|
|
my $windD = %{$json}{"currentobservation"}->{"Windd"};
|
|
|
|
my $desc = %{$json}{"currentobservation"}->{"Weather"};
|
|
|
|
|
2020-07-21 10:17:29 -06:00
|
|
|
print $desc.":".$temp.":".$windS.":".$windD.":".$loc;
|