How to use CGI

Moderator: leecollings

Post Reply
User avatar
Marq
Posts: 17
Joined: Sunday 26 April 2015 12:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

How to use CGI

Post 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
cul8r
Posts: 14
Joined: Tuesday 05 January 2016 23:03
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: How to use CGI

Post 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
User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: How to use CGI

Post 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.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest