luup.inet.wget problem

I am trying to set my foscam ftp interval parameter and I can’t get it to work using the following luup code.

luup.inet.wget(“http://192.168.1.105:8090/set_ftp.cgi?upload_interval=10,5,myuser,mypwd”)

Yet if I directly invoke the following url it works fine.

           http://192.168.1.105:8090/set_ftp.cgi?upload_interval=10,5,myuser,mypwd

What am I doing wrong?

should work. here’s another way to do it in LUUP:

os.execute('curl -d http://192.168.1.105:8090/set_ftp.cgi?upload_interval=10,5,myuser,mypwd')

Unfortuately, that did not work either.

I’ve tried different different formats etc. Wonder if it could be something with key word treatment or something.

My guess would be the Password you’ve used has a “special” character in it. Typically this would be anything that’s not Alpha-numeric.

If this is the case, then you’ll need to URL-Encode that when you build the URL call in [tt]wget[/tt] ([tt]curl[/tt], etc). Most browsers will auto-convert user-entered URLs to URL-encode stuff for you, so you may not notice it in a direct call.

The other possibility is that the receiving end is fussy about Headers being sent in the request. If this is the case, you’d need to work out which headers it’s fussy about and add them to the curl version of the script

Thanks guys for the replies. I am really at a loss…

There are no special characters in the myuser or mypwd that I am using - just alphanumerics.

I use the following luup code to set the foscam alarm variables and it works fine.

luup.inet.wget(“http://192.168.1.105:8090/set_alarm.cgi?motion_armed=1&motion_sensitivity=4&motion_compensation=1&upload_interval=5&user=myuser&pwd=mypwd”)

But the luup code below does not work. It appears to execute but does not change the ftp_upload_interval variable.

luup.inet.wget(“http://192.168.1.105:8090/set_ftp.cgi?upload_interval=10,5,myuser,mypwd”)

I also tried this form with the same result. I would guess the results here would not be what I want anyway since the ftp settings also have a user and pwd parameter.

luup.inet.wget(“http://192.168.1.105:8090/set_ftp.cgi?upload_interval=10&user=myuser&pwd=mypwd”)

Any more ideas?

It’s possible that one of the CGI’s is more fussy than another.

Check the Headers being sent by the Browser (using Firefox, or Chrome, for example) and then add them to the os.execute(…“curl”…) version of the call.

In another Plugin we had to add a bunch more headers to get the receiving end to process the request correctly.

[quote=“rdbrose, post:5, topic:173928”]Thanks guys for the replies. I am really at a loss…

There are no special characters in the myuser or mypwd that I am using - just alphanumerics.

I use the following luup code to set the foscam alarm variables and it works fine.

luup.inet.wget(“http://192.168.1.105:8090/set_alarm.cgi?motion_armed=1&motion_sensitivity=4&motion_compensation=1&upload_interval=5&user=myuser&pwd=mypwd”)

But the luup code below does not work. It appears to execute but does not change the ftp_upload_interval variable.

luup.inet.wget(“http://192.168.1.105:8090/set_ftp.cgi?upload_interval=10,5,myuser,mypwd”)

I also tried this form with the same result. I would guess the results here would not be what I want anyway since the ftp settings also have a user and pwd parameter.

luup.inet.wget(“http://192.168.1.105:8090/set_ftp.cgi?upload_interval=10&user=myuser&pwd=mypwd”)

Any more ideas?[/quote]
Would this work?

local url = require("socket.url") local link = url.escape(string.format("http://192.168.1.105:8090/set_ftp.cgi?upload_interval=10,5,myuser,mypwd")) luup.inet.wget(link)

Using this to get callerid from a fritzbox on a mythfrontend.

As I recall lua uppercased or lowercased the headers to conform to the standards.
The problem is that many web services do NOT conform to the standards.
So you have to manually added headers of the appropriate case to your request.
A lot of extra BS for something that should be a one liner …
Welcome to the world of programming!

… it does, but you only run into issues if you use LuaSocket for the HTTP calls themselves, and the receiving end isn’t standards compliant.

In this case, @capjay’s recommendation was to use [tt]os.execute()[/tt] and [native] curl. With a later recommendation, from @j.hoekstra, to use the URL-encoding methods of LuaSocket.

Ultimately, with this combination, they shouldn’t run into the LuaSocket HTTP problem you’re citing… but it’ll definitely be worthwhile maintaining the Header case in the curl call “just in case” the Foscam is non-standard.

Thanks guys - with your help and suggestions I’ve figured out what is going on.

The foscam set_alarm.cgi implementation works fine, but the foscam set_ftp.cgi implementation is not recognizing the user and password. When I used Chrome to invoke the set_ftp.cgi url I had to physically log-on before it would proceed and work. Whereas I did not need to physically log-on when invoking the set_alarm.cgi url.