20 lines
653 B
Bash
Executable File
20 lines
653 B
Bash
Executable File
#!/usr/bin/perl -w
|
|
use strict;
|
|
use warnings;
|
|
use JSON;
|
|
|
|
my $URL_lat = ($ARGV[0] or 40.4936);
|
|
my $URL_lon = ($ARGV[1] or -111.9388);
|
|
|
|
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";
|
|
|
|
my $json = decode_json $info or die "Error";
|
|
|
|
my $loc = %{$json}{"location"}->{"areaDescription"};
|
|
my $temp = %{$json}{"currentobservation"}->{"Temp"};
|
|
my $windS = %{$json}{"currentobservation"}->{"Winds"};
|
|
my $windD = %{$json}{"currentobservation"}->{"Windd"};
|
|
my $desc = %{$json}{"currentobservation"}->{"Weather"};
|
|
|
|
print $desc.":".$temp.":".$windS.":".$windD.":(WG)".$loc;
|