weatherget/wttrin.sh

17 lines
567 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 $loc = %{$json}{"nearest_area"}->[0]->{"areaName"}->{"value"};
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.":".$loc;