Super basic syntax question

Posted on
Tue Apr 12, 2016 10:30 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Super basic syntax question

Technically this is more "how does someone who doesn't know curl make this work" , but it crops up for me here because it's the first time I've tried something like this.

I'm trying to get WU's satellite image following their instructions at https://www.wunderground.com/weather/ap ... llite&MR=1

Well first off I have to curl not GET, but it seems to pull something from their servers. But it's all just going in the terminal. I've read the man page for curl, and this seems like it should work:

Code: Select all
curl http://api.wunderground.com/api/myAPIkeyHere/animatedsatellite/image.gif?lat=00&lon=00&radius=100 --output "/Users/myname/Desktop/"
nope. Junk to the terminal/STOUT

Code: Select all
curl http://api.wunderground.com/api/myAPIkeyHere/animatedsatellite/image.gif?lat=00&lon=00&radius=100 --output "/Users/myname/Desktop/satellite.gif"
also nope. These also nope when I use -o instead of -output or when I try the -G option:

Code: Select all
curl -G http://api.wunderground.com/api/myAPIkeyHere/animatedsatellite/image.gif?lat=00&lon=00&radius=100 --output "/Users/myname/Desktop/satellite.gif"
"myAPIkey" is replaced with my actual API key and the real lat and longitude are in the actual URLs I tried.

Any help? I'm sure someone here has this working.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Apr 12, 2016 10:56 am
forestfield offline
Posts: 83
Joined: Dec 29, 2014
Location: West Sussex

Re: Super basic syntax question

Quick guess. If you're running this from the command line, the & in the url is being interpreted by the command line shell, and you need to escape it.

One way to do this is to put the url in ' or " characters, i.e.

curl "http://api.wunderground.com/api/myAPIkeyHere/animatedsatellite/image.gif?lat=00&lon=00&radius=100" --output "/Users/myname/Desktop/satellite.gif"

This gives me an "this key does not exist" error - which is what I'd expect, not having an api key.

Posted on
Tue Apr 12, 2016 11:31 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: Super basic syntax question

Totally worked! Well, kinda. The GIF that downloads is blank, but that's a different problem.

Thanks very much.

So now I wonder under what circumstances the examples used in man curl DO work. Shell scripts?

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Apr 12, 2016 1:19 pm
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Super basic syntax question

Just a heads up that as yet, natively anyway, animated gifs aren't supported on control pages.

Carl

Posted on
Tue Apr 12, 2016 2:57 pm
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: Super basic syntax question

The animated gif is working on my page.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Apr 12, 2016 3:01 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Super basic syntax question

In my experience, animated GIFs *will* animate in a browser, but will not animate in Indigo Touch.


Sent from my iPhone using Tapatalk

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Apr 12, 2016 3:29 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Super basic syntax question

DC -

First, GET is an http command type, like POST. You're using the "curl" command line utility to send HTTP commands. The default for curl is to do a GET, so you don't need to specify it. The full form of the command would be

Code: Select all
curl --get "http://api.wunderground.com/api/myAPIkeyHere/animatedsatellite/image.gif?lat=00&lon=00&radius=100" --output "/Users/myname/Desktop/satellite.gif"


So now I wonder under what circumstances the examples used in man curl DO work. Shell scripts?


I think you missed this line in the man page:

When using [] or {} sequences when invoked from a command line prompt, you probably have to put the full URL within double quotes to avoid the shell from interfering with
it. This also goes for other characters treated special, like for example '&', '?' and '*'.


None of the examples on the man page have an ampersand in them, so they don't show the quotes.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests