weatherget/wttrin.sh
2020-01-21 15:10:25 -07:00

16 lines
492 B
Bash
Executable File

#! /usr/bin/perl -w
use strict;
use warnings;
use JSON;
my $info = `curl -sm 5 wttr.in/bluffdale?format=j1` or die "Error";
my $json = decode_json $info or die "Error";
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;