[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4694: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4695: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4696: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
8devices Community - View topic - LUA program executing with UHTTPD
www.8devices.com
View unanswered posts | View active topics It is currently 27 Apr 2024, 23:47



Reply to topic  [ 6 posts ] 
 LUA program executing with UHTTPD 
Author Message

Joined: 18 Jan 2013, 12:13
Posts: 8
Hi

I have started to develop LUA programs with UHTTPD, however, I am stuck as follows:

my HTTPD configuration:
root@OpenWrt:~# uci show uhttpd
uhttpd.main=uhttpd
uhttpd.main.listen_http=0.0.0.0:80
uhttpd.main.listen_https=0.0.0.0:443
uhttpd.main.home=/www
uhttpd.main.rfc1918_filter=1
uhttpd.main.max_requests=3
uhttpd.main.cert=/etc/uhttpd.crt
uhttpd.main.key=/etc/uhttpd.key
uhttpd.main.cgi_prefix=/cgi-bin
uhttpd.main.script_timeout=60
uhttpd.main.network_timeout=30
uhttpd.main.tcp_keepalive=1
uhttpd.main.lua_handler=/usr/lib/lua/luci/sgi/uhttpd.lua
uhttpd.main.lua_prefix=/cgi-bin
uhttpd.px5g=cert
uhttpd.px5g.days=730
uhttpd.px5g.bits=1024
uhttpd.px5g.country=DE
uhttpd.px5g.state=Berlin
uhttpd.px5g.location=Berlin
uhttpd.px5g.commonname=OpenWrt


my LUA program
root@OpenWrt:/www/cgi-bin# cat cgiinlua
#!/usr/bin/lua

--[[
This is a simple demonstration of CGI (Common Gateway
Interface) programming in Lua.
]]

print ("Content-type: Text/html\n")

local info = os.getenv("QUERY_STRING")
local params = {}
local echo = {}

for name, value in string.gmatch(info .. '&', '(.-)%=(.-)%&') do
value = string.gsub(value , '%+', ' ')
value = string.gsub(value , '%%(%x%x)', function(dpc)
return string.char(tonumber(dpc,16))
end )
params[name] = value

value = string.gsub(value, "%&", "&")
value = string.gsub(value, "%<", "&lt;")
value = string.gsub(value, '%"', "&quot;")
echo[name] = value

end

pagetop = [[<html><head><title>A Web page in Lua</title></head>
<body text=blue><h1>Calculate VAT at 15.0%</h1>
A Lua script with form fill ... <br><br>
<form>Net amount: <input name=net> and <input type=submit value="go!"></form>
<br><br>Result:<br><br>
]]
print (pagetop)

if params["net"] ~= "" and params["net"] ~= nil then
inval = tonumber(params["net"])
if inval == nil then
print ("Not a number - can't calculate")
else
print (inval * 1.15)
end
print ("<br><i>input value was</i><br>")
print (echo["net"])
else
print "<i>will appear here</i>"
end

pagebase = [[<br><br>
Sample Page in Lua by
<a href=http://www.wellho.net>Well House Consultants</a> &copy; 2008
</body></html>
]]

print (pagebase)



I have tried different directories in /www (e.g. /lua instead of /cgi-bin) and different configs (e.e. from OpenWrt web site), however, when calling the program from the browser (192.168.0.188/cgiinlua) then the browser (both IE and Chrome) only print the lua file, but not displays the HTML as expected.

Also, I have a problem restarting the UHTTP server. stop works, but restart fails, the server displays

root@OpenWrt:/usr/bin# uhttpd restart
Error: No sockets bound, unable to continue
root@OpenWrt:/usr/bin# uhttpd restart -p 80
bind(): Address already in use
bind(): Address already in use
Error: No sockets bound, unable to continue


Would very much appreciate help, thanks Emmerich


24 Jan 2013, 16:30
Profile

Joined: 18 Jan 2013, 12:13
Posts: 8
I am still not any further despite trying all kinds of deroutes.

I have though found that there is no file uhttpd.lua in the directory usr/lib/lua/luci/sgi

Is that a concern? Where should I get the file from?


Since I am pretty desparate would appreciate any possible help. :?

Emmerich


10 Mar 2013, 16:45
Profile

Joined: 26 May 2012, 01:19
Posts: 66
What does this have anything to do with carambola? You're better off asking openwrt forum.


10 Mar 2013, 19:39
Profile

Joined: 18 Jan 2013, 12:13
Posts: 8
Hi Bluespray

had a few days with members from the OpenWrt community, see that forum .... (openwrt.org ... forum ... general discussion)

However, they could not help and it sounds like the problem is deeper in the way how Luci, uHTTPD and Lua have been set up on the Carambola device, which seems unique.

The latest simple program we tested with is as follows
#!/usr/bin/lua


local function main()
print("Content-Type: text/html")
print("")
print("<!DOCTYPE html>")
print("Hello World! ... wenn nicht.")
end


main()


They said it works fine on their installations (we compared syntax, config files, etc), it just doesn't get interpreted by lua when put into the /www/cgi-bin directory and called 192.168.0.114/cgi-bin/main.lua


Since I don't know any further at this time I may have now to put the Carambola device onto the shelf, reluctantly ... unless miracles will happen :cry: .

Thanks and regards, Emmerich


13 Mar 2013, 22:43
Profile

Joined: 14 Mar 2013, 16:24
Posts: 2
Hello,
I just have the same problems:
Tried it with
Php
Lua
Sh
Scripts...
The scripts run perfectly from the shell, but not
via uhttpd -> browser only asks to dowload/save the
Script file. (Cache off, various browsers tested...)

I'll try busybox httpd or lighttpd...


15 Mar 2013, 17:45
Profile

Joined: 20 Mar 2013, 18:45
Posts: 1


20 Mar 2013, 18:59
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Protected by Anti-Spam ACP Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.