如何在LuCI里添加print?
来源:互联网 发布:淘宝自动刷单平台 编辑:程序博客网 时间:2024/05/16 10:47
这个方式是从openwrt的maillist里找到的,适合那些想修改luci,但是对lua语言又不熟悉的人。
大意如下:
某人问在LuCI里添加print("hello"),出现错误。为啥?
attempt to call global 'print' (a nil value)
然后,下面有个人回复说,需要在文件开头添加这么一行:
local print = print因为这个文件是一个module,它调用了module函数。详细信息,可以参考Lua手册
原文如下:
Hi all,when i add above 'print("hello")' in /usr/lib/lua/luci/model/uci.luagot follow error:/usr/lib/lua/luci/dispatcher.lua:448: Failed to execute call dispatchertarget for entry '/servicectl/restart/firewall'.The called action terminated with an exception:/usr/lib/lua/luci/model/uci.lua:71: attempt to call global 'print' (a nilvalue)stack traceback:[C]: in function 'assert'/usr/lib/lua/luci/dispatcher.lua:448: in function 'dispatch'/usr/lib/lua/luci/dispatcher.lua:195: in function </usr/lib/lua/luci/dispatcher.lua:194>why cannot use print to print some value?thanks all!elvis--------------------------------------------------------------------------------------You need to define it first at the top of the file:diff --git a/libs/core/luasrc/model/uci.lua b/libs/core/luasrc/model/uci.luaindex a394563..f513c77 100644--- a/libs/core/luasrc/model/uci.lua+++ b/libs/core/luasrc/model/uci.lua@@ -27,6 +27,7 @@ local os = require "os" local uci = require "uci" local util = require "luci.util" local table = require "table"+local print = printWhy? It's because of the following function call:module "luci.model.uci"For the details, read the fine Lua manual[1]. BTW, it's better to use file fordebugging output, since you can easily loose some hairs with stdout/stderrdebugging in the Luci development :-)1. http://www.lua.org/manual/5.1/manual.html#pdf-module
0 0
- 如何在LuCI里添加print?
- 如何在TLISTVIEW里添加背景色
- 如何在开始菜单里添加快捷方式???
- 在WORD文档里如何添加编号
- 如何在UITableView里动态添加 cell
- 如何在Retrofit请求里添加Cookie
- 如何在Word工具栏里添加MathType
- 如何批量在mysql里添加数据
- 如何在命令行里添加 第三方包到 classpath里?
- 如何在eclipse里添加logcat,以及添加过滤器
- 在luci中添加一个页面的方法
- 在OpenWrt路由器上添加LuCI的模块
- wifidog在OpenWrt路由器上添加LuCI的模块
- luci 添加helloword模块
- 如何在同一个工程里添加多种语言
- 请教:如何在PB的主窗口里添加背景图?
- 如何在ie主菜单里添加顶部菜单项
- 如何在同一个工程里添加多种语言
- 网页定时刷新
- SAP ABAP开发顾问面试题云集(二)
- Android 中四种存储方式及preference
- CMOS中如何设置定时开机功能
- get和post请求方式的区别
- 如何在LuCI里添加print?
- win8 配置IIS和添加网站
- gentoo安装skype
- 二叉树遍历的非递归实现
- outlook中实现邮件自动回复
- Users and Responsibilites in Oracle EBS
- Java中抽象类和接口的区别
- ThreadLocal原理介绍
- vs2008 编译 live555