Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Howto: CLI Weather Forecast

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2029
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 139 times
Been thanked: 206 times

Howto: CLI Weather Forecast

#1 Post by Hallvor »

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 istanbul
Image
Last edited by Hallvor on 2018-03-05 09:40, edited 1 time in total.
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

User avatar
None1975
df -h | participant
df -h | participant
Posts: 1389
Joined: 2015-11-29 18:23
Location: Russia, Kaliningrad
Has thanked: 45 times
Been thanked: 66 times

Re: Howto: CLI Weather Forecast

#2 Post by None1975 »

Nice tutorial. Thanks :)
OS: Debian 12.4 Bookworm / DE: Enlightenment
Debian Wiki | DontBreakDebian, My config files on github

User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2029
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 139 times
Been thanked: 206 times

Re: Howto: CLI Weather Forecast

#3 Post by Hallvor »

None1975 wrote:Nice tutorial. Thanks :)
Glad you liked it. :)
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

User avatar
jheaton5
Posts: 1488
Joined: 2008-08-20 01:40
Location: Newnan, GA, USA

Re: Howto: CLI Weather Forecast

#4 Post by jheaton5 »

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
RU55EL
Posts: 546
Joined: 2014-04-07 03:42
Location: /home/russel

Re: Howto: CLI Weather Forecast

#5 Post by RU55EL »

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'

Post Reply