OpenWrt Forum Archive

Topic: Bad Gateway The process did not produce any response.

The content of this topic has been archived on 25 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi ,

I have following question to understand.

1. How to enable debugs in luci package ?
2. how to debug lua files at run time. say i have xxxx.lua and added some "print" to print some patameter values.
    for example:

                 local arptable = luci.sys.net.arptable() or {}
                 for i, dataset in ipairs(arptable) do
                      print(i)                         // wanted to print value of i and dataset
                      print(dataset)
                      ip:value(
                                    dataset["IP address"],
                                     "%s (%s)" %{ dataset["IP address"], dataset["HW address"] }
                       )
                  end
so when we try to load the page we get error "Bad Gateway The process did not produce any response"  but as soon as if we delete the print statement page loads without any issue.

3. do we have any document to understand complete flow of the luci framework in openWRT .( like how bottons are works, how uci involed from lua to write or read config files etc..,)

any answers ?

use .htm files to display parameters

But my requirement is to debug lua files not htm files. smile

for examlpe in lua use

uptime     = net:uptime()

and in .htm

html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime);
d.innerHTML = html;

May be the question is not clear to you, my requirement is on dynamically running lua files, if i want print some parameter values as show in above example, is there any mechanism to print those values or its not possible to print the lua files values.
may be m not clear with your answer please correct me if m wrong.

 ip:value(
                dataset["IP address"],
                "%s (%s) i=%d, %s, %s" %{ dataset["IP address"], dataset["HW address"], i, dataset["HW type"], dataset["Device"] }
        )

(Last edited by neryba on 21 Aug 2013, 10:26)

arptable ()
Returns the current arp-table entries as two-dimensional table.
Return value:
Table of table containing the current arp entries. The following fields are defined for arp entry objects: { "IP address", "HW address", "HW type", "Flags", "Mask", "Device" }

topic is diverting..., i wanted in genral how one can debug lua files at run time, how we do with C files by putting "printf" similarly do we have any mechnism to do it here. arptable  function have taken as example in this post.

In many contexts you cannot simply print since no http headers have been sent yet so the cgi program will produce invalid output.
You can either use nixio.syslog() to write text to logread or you can open a file and write your debug info there, eg. handle = io.open("/tmp/debug", "w") once and then handle:write() to log data.

A third approach is wrapping the luci cgi-programm in a script:

#!/bin/sh

exec 2>/tmp/debug
exec /www/cgi-bin/luci

Place that in /www/cgi-bin/luci.dbg and chmod it to 0755.
Call the gui with http://192.168.1.1/cgi-bin/luci.dbg and use io.stderr:write() to log data to /tmp/drbug.

The discussion might have continued from here.