weatherget/wttrin.sh

19 lines
617 B
Bash
Raw Normal View History

2020-01-21 14:01:04 -07:00
#! /usr/bin/perl -w
use strict;
use warnings;
use JSON;
my $city = $ARGV[0] or scalar("bluffdale");
my $info = `curl -sm 5 wttr.in/$city?format=j1` or die "Error";
2020-01-21 14:01:04 -07:00
my $json = decode_json $info or die "Error";
my $loc = %{$json}{"nearest_area"}->[0]->{"areaName"}->[0]->{"value"};
2020-01-21 14:01:04 -07:00
my $temp = %{$json}{"current_condition"}->[0]->{"temp_F"};
my $windS = %{$json}{"current_condition"}->[0]->{"windspeedMiles"};
my $windD = %{$json}{"current_condition"}->[0]->{"winddirDegree"};
my $desc = %{$json}{"current_condition"}->[0]->{"weatherDesc"}->[0]->{"value"};
print $desc.":".$temp.":".$windS.":".$windD.":(WT)".$loc;