DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD Packages and Ports

OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 12th November 2018
Prevet Prevet is offline
Fdisk Soldier
 
Join Date: Oct 2017
Posts: 82
Default GKrellM weather plugin woes

http://openports.se/sysutils/gkrellm/plugins/weather

I'm having a little trouble getting this to work right. Out of the box the plugin doesn't give the weather. So I found this link that says to update a weblink in the script '/usr/local/bin/gkrellm.GrabWeather'

https://groups.google.com/forum/#!to...st/zilMiI9WHRI

But when I make the change and run gkrellm it says:

Quote:
unable to fetch weather: 0 at /usr/local/bin/gkrellm.GrabWeather line 46.
This is the line it stops on in the code below:
Code:
 die "unable to fetch weather: $?" if `$cmd` == 0;
Code:
# Is LWP installed?
eval { require LWP::UserAgent };
if ($@) {
  my $cmd = qq{ftp -o $home/$ReportDir/$HTMLFileName $URL};
  die "unable to fetch weather: $?" if `$cmd` == 0; 
} else {
  $ENV{FTP_PASSIVE} = 1; # LWP uses Net::FTP internally.
  my $ua  = new LWP::UserAgent;
  my $req = new HTTP::Request( GET => $URL );
  my $rsp = $ua->request( $req );
  die $rsp->status_line unless $rsp->is_success;
  my $fh = new IO::File "> $home/$ReportDir/$HTMLFileName" 
    or die "unable to write '$home/$ReportDir/$HTMLFileName': $!";
  print $fh $rsp->content;
  close $fh or die "error closing '$home/$ReportDir/$HTMLFileName': $!";
}
Does it need LWP or is the script broken? Is LWP a specific package?

It is definately getting the data from the website. When I hover the mouse over it a text file with all the weather data appears, however the interface just shows. +0C -99%. It is a great program otherwise.
Reply With Quote
  #2   (View Single Post)  
Old 12th November 2018
shep shep is offline
Real Name: Scott
Rc.conf Instructor
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,191
Default

I have 3 small scripts that retrieve and display current conditions, forecast and animated weather radar. The scripts utilize no cpu cycles or bandwidth until run. I had to adjust my scripts when sites were migrated in the US and I'm also aware that the gnome/xfce4 weather applets had to be redone for the same reasons. I'd be glad to post the scripts if there is interest.

Edit: I looked at your link and my scripts had the same issue. These currently work

Current METAR:

Code:
#!/bin/ksh
xterm -g 70x15-1+39 -T "Yakima, WA Weather" -hold -e \
curl -sk http://tgftp.nws.noaa.gov/data/observations/metar/decoded/KYKM.TXT
KYKM is the Airport ICAO for my nearby Airport.
https://en.wikipedia.org/wiki/List_o...tion_indicator


Forecast:

Code:
#!/bin/ksh
xterm -g 125x46-1+38 -T "Yakima, WA Weather" -hold -e "curl http://wttr.in/~Yakima+WA"
http://wttr.in


Radar:

Code:
#!/bin/ksh

# This is a simple script that downloads a radar image from
# Wunderground weather and plays back with ImageMagick

# The script is configured for US Pacific NW composite radar 
# To change the site edit the https site
# Browse https://www.wunderground.com/maps/catalog/ for *.gifs (animated)
curl https://icons.wxug.com/data/weather-maps/radar/united-states/redmond-oregon-region-current-radar-animation.gif | \
 animate -immutable -loop 0 -title "NorthWest Radar Loop"

Last edited by shep; 13th November 2018 at 04:13 PM. Reason: Somehow my paste produced a double entry ?press/release
Reply With Quote
  #3   (View Single Post)  
Old 13th November 2018
Prevet Prevet is offline
Fdisk Soldier
 
Join Date: Oct 2017
Posts: 82
Default

Thanks for those shep. Great scripts.

Last edited by Prevet; 13th November 2018 at 12:59 AM.
Reply With Quote
  #4   (View Single Post)  
Old 13th November 2018
fvgit's Avatar
fvgit fvgit is offline
Tempvs fvgit
 
Join Date: May 2016
Location: perl -MMIME::Base64 -le 'print decode_base64("SGVyZSBiZSBkcmFnb25zC")'
Posts: 154
Default

Nice indeed!

BTW, you don't always need to install curl. For instance, you could rewrite the wttr.in example so that it works with the ftp command in the base system like this:
Code:
#!/bin/ksh
xterm -g 125x46-1+38 -T "Yakima, WA Weather" -hold -e "ftp -VM -o - -U curl/7. http://wttr.in/~Yakima+WA"
The ftp options explained:
  • -V # disable verbose mode
  • -M # don't display progress meter
  • -o - # redirect output to STDOUT
  • -U curl/7. # set user-agent to curl/7. <---- this is where the magic happens
Reply With Quote
  #5   (View Single Post)  
Old 13th November 2018
shep shep is offline
Real Name: Scott
Rc.conf Instructor
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,191
Default

I have some diversity in my 3 computers all of which dual-boot: Debian 9+OpenBSD stable, Fedora 29+OpenBSDcurrent/SimpleDE and Arch Linux+OpenBSDcurrent porting efforts.

I recall that Debian disabled ImageMagick's ability to fetch web content as a security issue. Adding curl made the scripts usable on all my systems. I use BSD tools in Debian and Fedora and will trial your ftp suggestion. Will OpenBSD's ftp retrieve from https?

Last edited by shep; 13th November 2018 at 05:41 PM.
Reply With Quote
  #6   (View Single Post)  
Old 13th November 2018
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 828
Default

Quote:
Originally Posted by shep View Post
Will OpenBSD's ftp retrieve from https?
Yes.
Reply With Quote
  #7   (View Single Post)  
Old 13th November 2018
fvgit's Avatar
fvgit fvgit is offline
Tempvs fvgit
 
Join Date: May 2016
Location: perl -MMIME::Base64 -le 'print decode_base64("SGVyZSBiZSBkcmFnb25zC")'
Posts: 154
Default

Shep, using ftp works for me on all of the three scripts you posted, including https connections.

By the way, the curl user agent is only necessary for wttr.in. I think that site does a check for the user agent and delivers different output otherwise. At least that was the case when I played with it a couple of months ago. Oh, and thanks for the METAR one! I tested it with the three nearest airports in my area and it even receives data supplied by the big NATO airbase not too far from my town. Very cool.
Reply With Quote
  #8   (View Single Post)  
Old 13th November 2018
shep shep is offline
Real Name: Scott
Rc.conf Instructor
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,191
Default

If you are in the US, you can get individual radar station gifs directly from weather.gov.
Code:
https://radar.weather.gov/ridge/lite/NCR/PDT_loop.gif
NOAA provides Forecasts geared towards Aviation safety

Code:
http://tgftp.nws.noaa.gov/data/forecasts/zone/wa/waz027.txt
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
USB modem woes Paianni OpenBSD General 2 25th August 2018 05:54 PM
Xorg woes... jb_daefo FreeBSD General 1 5th June 2011 04:35 AM
torsmo displaying weather question neurosis FreeBSD General 6 20th October 2008 10:53 PM
widescreen woes jbhappy FreeBSD General 8 25th June 2008 08:25 PM
gkrellm launches slowly hydra FreeBSD Ports and Packages 1 16th May 2008 07:00 PM


All times are GMT. The time now is 07:18 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick