Howto: CLI Weather Forecast

Share your own howto's etc. Not for support questions!

Howto: CLI Weather Forecast

Postby Hallvor » 2017-07-25 21:08

If you (like I do) check the weather several times a day, this will come in handy!

You don't even need a web browser. :D
Image

First, test it out in the terminal:
Code: Select all
$ curl -4 http://wttr.in/Paris


You should now get a nice forecast for the next three days in Paris. Try another city by replacing Paris with what you want.

If you like this tool, let's make a script to make it possible for you to get the forecast of your city just by typing wttr in the command line.

As root:

Code: Select all
# nano /bin/wttr


Paste the following content into the file:

Code: Select all
#!/bin/bash
CITY=${1:-Kristiansand}
curl -4 http://wttr.in/${CITY}


The second line states the default city. Replace it with the city closest to you.

Save and exit. (In nano this is done by pressing Ctrl + X, and then Y to save.)

You now only need to make the script executable (as root).

Code: Select all
# chmod +x /bin/wttr


All done!

Now you can check the weather forecast where you live by typing (as regular user)

Code: Select all
$ wttr


in the terminal.

If you want to check the weather in, say, Istanbul, just type

Code: Select all
$ wttr instanbul


Image
Intel Core i5 3320-M CPU @ 2.60 GHz, 6 GB RAM, Intel HD 4000 graphics, 300 GB HDD, Debian Stretch (KDE)
User avatar
Hallvor
 
Posts: 739
Joined: 2009-04-16 18:35
Location: Norway

Re: Howto: CLI Weather Forecast

Postby None1975 » 2017-07-26 13:33

Nice tutorial. Thanks :)
OS: Debian 8.9 / WM: xmonad
Debian Wiki | DontBreakDebian
User avatar
None1975
 
Posts: 189
Joined: 2015-11-29 18:23
Location: Lithuania

Re: Howto: CLI Weather Forecast

Postby Hallvor » 2017-07-26 13:35

None1975 wrote:Nice tutorial. Thanks :)


Glad you liked it. :)
Intel Core i5 3320-M CPU @ 2.60 GHz, 6 GB RAM, Intel HD 4000 graphics, 300 GB HDD, Debian Stretch (KDE)
User avatar
Hallvor
 
Posts: 739
Joined: 2009-04-16 18:35
Location: Norway

Re: Howto: CLI Weather Forecast

Postby jheaton5 » 2017-08-10 11:09

Thanks,
I like the cli weather report. One question: How do you enter the name of a city with two names like "New York"? I entered New York and got the weather report for York, UK.

Edit: I got it. Looked at the wttr.in site in github: https://github.com/chubin/wttr.in

$New+York.
debian sid
User avatar
jheaton5
 
Posts: 1489
Joined: 2008-08-20 01:40
Location: Newnan, GA, USA

Re: Howto: CLI Weather Forecast

Postby RU55EL » 2017-08-10 13:03

You can also check the weather using a website.

This will give you the weather report for Mountain View, USA:
Code: Select all
curl wttr.in/@google.com


[edit]

You can enter New York the old fashion way:

Code: Select all
curl wttr.in/'new york'
User avatar
RU55EL
 
Posts: 310
Joined: 2014-04-07 03:42
Location: /home/russel


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable