Results 1 to 4 of 4

Thread: Simple weather forecast using terminal

  1. #1
    Join Date
    Jan 2014
    Beans
    8

    Simple weather forecast using terminal

    I installed the weather-util package and any dependencies:
    Code:
    sudo apt-get install weather
    I first created a "/scripts" directory in my home folder:
    Code:
    barry@barry:~$ mkdir scripts
    Then I created a simple bash script which I called "forecast", saving in the new folder. Just cut and paste the code below into a text file, naming it "forecast". Change the zip code (shown below as 74012) to whatever you want:
    Code:
    #!/bin/bash
    clear
    echo "Today's date is `date`"
    echo "Here are your local weather conditions and forecast:"
    weather --forecast -a --no-cache-data 74012 | more
    echo ""
    echo "**************************************END********************************
    I then made the script executable. Open a terminal, change to the "scripts" directory you created above and type:
    Code:
    chmod +x forecast
    Then I added a PATH variable to my .bashrc file located in my home folder:
    Code:
    barry@barry:~$export PATH=~/scripts:$PATH
    Whenever I want to see a quick forecast, I open up a terminal and simply type
    Code:
    forecast
    which yields the following (hope the screenshot works):[IMG]file:///home/barry/Pictures/Screenshot.png[/IMG]
    edit: well the screenshot doesn't want to load....will work on later....B
    Last edited by barryww1956; February 4th, 2014 at 08:03 PM.

  2. #2
    Join Date
    Sep 2006
    Beans
    7,628
    Distro
    Lubuntu Development Release

    Re: Simple weather forecast using terminal

    Cool.

    Alternately, if you make a ~/bin directory and put the script there, then next time you log in, it should be in your $PATH.

    With printing the date, you can use parentheses instead of backticks. But it's also possible to use date by itself.

    Code:
    date +'Today's date is %a %b %e %T %Z %Y'
    date +"Today's date is %a %b %e %T %Z %Y"
    You might also look at using conky for posting weather info, but that's outside of the terminal and on the desktop GUI.
    Last edited by Lars Noodén; February 5th, 2014 at 08:04 AM. Reason: fixed quotes

  3. #3
    Join Date
    Jan 2014
    Beans
    8

    Re: Simple weather forecast using terminal

    The man pages on weather gives some other things to play with too. Lots of ways to accomplish the same thing in Linux is there not? I like that cause there should be at least one that works even for me. Don't guess I can post a screenshot as this is only my second post, if I read the rules right I need at least ten. I'll eventually get there. I like terminal apps like these due to their low overhead, and my laptop is due for replacement. But that's another subject.

  4. #4
    Join Date
    Feb 2007
    Location
    West Hills CA
    Beans
    8,581
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Simple weather forecast using terminal

    A little correction:

    Code:
    date +"Today's date is %a %b %e %T %Z %Y"
    The apostrophe needs quotes as the delimiter, otherwise the date command (within bash) gets confused.
    -------------------------------------
    Oooh Shiny: PopularPages

    Unumquodque potest reparantur. Patientia sit virtus.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •