Page 1 of 1

How to use CGI

Posted: Saturday 06 February 2016 11:13
by Marq
'
Hi,
I have a device (camera Foscam FI9821w v2 to be exact), from which the status can be queried by executing a CGI command:

Code: Select all

http://192.168.1.2/cgi-bin/CGIProxy.fcgi&usr=admin&pwd=123&cmd=ABC


a webpage is opened which shows the status, eg.:

Code: Select all

<CGI_Result>
     <result>0</result>
     <isDHCP>1</isDHCP>
     <ip>192.168.1.8</ip>
     <gate>0.0.0.0</gate>
     <mask>255.255.255.0</mask>
</CGI_Result> 


I am looking for a way to use this info in LUA.

Anyone know how to do it ?
A short example / guide would be helpfull.

Thanks, Mark

Re: How to use CGI

Posted: Sunday 07 February 2016 19:19
by cul8r
The only way in LUA that I know is to go via a file (but I am not a LUA expert):

os.execute('curl "http://192.168.1.2/cgi . . . (your cgi command) . . ." > /home/pi/xxx.txt')

then in LUA open the file and read what you need.

/C

Re: How to use CGI

Posted: Sunday 07 February 2016 21:24
by nayr
what exactly in the response do you want, none of that information looks usefull..

you can issue http get requests blindly without parsing the response, there are a few ways to do it.. OpenURL in lua is one way, blocky has the same function and switches can also make requests to url's.