Problem Description
I have some code that I've inherited and I'm trying to debug. It's a web application that is written in lua for the back end.
The system fails right now with an error that says the following:
398: attempt to call global 'require' (a nil value)
Code
Line 398 is the require statement you see below..
getstatus = function()
require("processinfo")
local value,errtxt=processinfo.package_version(packagename)
etc...
What I've tried so far:
I've tried to test to make sure that the package / module it's looking for exists. It does. It's in my lua lib folder
test-dev:/usr/share# find / -name processinfo*
/usr/share/lua/5.1/processinfo.lua
I've also launched the lua command line and tried to include the module, like so:
test-dev:/usr/share# lua
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
require("processinfo")
And it seems to be happy, no error messages.
Finally, I've tried to move the require statement from line 398 to the top of the file with the rest of the include statements that I have ... like so:
module(..., package.seeall)
posix = require("posix")
utils = require("utils")
processinfo = require("processinfo")
When I do that, the error message about the require statement goes away but instead i get an error about the string function I'm calling. The error message is :
139: attempt to index global 'string' (a nil value)
Line 139 is the opening of a while loop that looks like this:
while string.find(result, "%$[%w_]+") do
-- do something
end
Additional Information
Lua version is 5.1
this code is working on another server...
Related
tl;dr: renderLayout(layout="myLayout", view="alpha/bravo/viewFile") resolves alpha as a module name rather than a package name in the host application, even if code execution is in the package rather than the module.
How do I get the path resolution to be consistent when either running the handler directly or when calling it via runEvent from a module?
I posted this on the CB google group, but then thought it may be best to ask here.
Working example here: https://github.com/jinglesthula/cbModuleExample
If you run install (I .gitignored the coldbox folder), then cd into the /app folder and server start --rewritesEnable you can visit http://127.0.0.1:<whatever port>/example/admin/test/ajax to see it in action.
From the example:
/app/modules_app/example/handlers/admin/test.cfc -> ajax() calls runEvent("admin.test.ajax")
/app/handlers/admin/test.cfc -> ajax() calls `renderLayout( layout = "layout.div", view = "admin/test/ajax" )
"admin/test/ajax" normally resolves to /app/views/admin/test/ajax.cfm, but in this case it's resolving to /app/modules_app/admin/views/test/ajax.cfm.
You can comment out line 18 and uncomment line 19 in /modules_app/example/admin/handlers/test.cfc to see a workaround.
You can also go to /admin/test/ajaxDirect in your browser to see that the renderLayout() call in the non-working example is correct.
Note: I have this.viewParentLookup = true in my ModuleConfig.cfc. I've tried reloading the module with it set to false and I get the same result.
I have a Powershell (v2.0) script that I am working on.
One of the first things it does is loads a Module (runMySQLQuery.psm1) which includes (amongst other bits) a function to connect to a MySQL Database.
Import-Module runMySQLQuery.psm1
However, this requires that an assembly MySQL.Data.DLL is loaded in order for this to work.
If I place the line:
[void][system.reflection.Assembly]::LoadFrom("C:\PowerShell\modules\runMySQLQuery\MySql.Data.dll")
at the top of my script (separate to the Import-Module entry), then the whole thing works fine.
But I want to be able to load this assembly at the same time as the module, so that I don't have to worry about forgetting to including the assembly each time I use this module.
I tried placing it at the top of the .psm1 file, but that didn't work.
I then added it to my manifest file as:
RequiredAssemblies = #("C:\PowerShell\modules\runMySQLQuery\MySql.Data.dll")
This also didn't work.
Am I missing something here, is there a proper way to include assemblies as part of a module?
n.b. the error I get when it hasn't loaded properly is:
You cannot call a method on a null-valued expression
Can you just try to assign a varialbe a the beginig of you module :
$dumy = [system.reflection.Assembly]::LoadFrom("C:\PowerShell\modules\runMySQLQuery\MySql.Data.dll")
I have a variable defined in foo_const.v which is defined like this in foo_const.v:
localparam NUM_BITS = 32;
Then I have another file foo_const_slice.v which does this:
localparam SLICE_ADDR_BITS = NUM_BITS;
This compiles fine with the vcs command:
vcs -sverilog foo_const.v foo_const_slice.v
But when I try to use QuestaSim:
vlog -work work -sv foo_const.v foo_const_slice.v
I get the following error message:
** Error: foo_const_slice.v(46): (vlog-2730) Undefined variable: 'NUM_BITS'.
The problem is that by default, each file that vlog compiles goes into a separate compilation unit, just like C/C++ and many other languages. By default, vcs concatenates all files together into a single compilation unit.
Although there is a way to change the default (you can look it up in the user manual), the proper way to code this is to put your parameters in a package, and import the package where needed.
Dave
I have following problem. I would like to use jsShell.dll (Link to dll and description) in my project. I use Win7 64 bit.
I downloaded dll and put it in C:\Windows\system\jsshell (files jsShell.dll and khook.dll)
I succesfully registered dll using c:\Windows\SysWOW64> regsvr32.exe c:\Windows\system\jsshell\jsShell.dll (it is not needed to register khook.dll)
Then I tried to run test file jsshell\jsShell DLL\demo scripts\window.vbs which is part of jsShell.zip by:
a) double click to window.vbs and getting following error:
SCRIPT: C:\Users\joe\Downloads\jsshell\jsShell DLL\demoscripts\windows.vbs
LINE: 6
CHAR: 3
ERROR: ActiveX component can't create object: 'jsShell.Ops'
CODE: 800A01AD
SOURCE: Microsoft VBScript runtime error
This is the line with error: Set jsS = CreateObject("jsShell.Ops")
b) loading in WEB-ED Editor (Link to WEB-EDD) and running script over via editor, which works perfectly.
Could somebody please explain me, where is the difference between (a) and (b)? And what have to be done in order to run my script using (a) variant?
Thx a lot
In a previous ticket i asked about logging PHP errors in MySQL which gives me:
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
// mysql connect etc here...
$sql = "INSERT INTO `error_log` SET
`number` = ".mysql_real_escape_string($errno).",
`string` = ".mysql_real_escape_string($errstr).",
`file` = ".mysql_real_escape_string($errfile).",
`line` = ".mysql_real_escape_string($errline);
mysql_query($sql);
// Don't execute PHP internal error handler
return true;
}
// set to the user defined error handler
$new_error_handler = set_error_handler("myErrorHandler");
I can make this work but only if it is triggerred like this:
trigger_error("message here");
However, I also want the error handler to be called for all errors such as syntax errors like:
echo "foo;
But these errors are just outputted to the screen, what am i doing wrong?
You can only handle runtime errors with a custom error handler. The echo "foo error in your example happens when parsing (i.e. reading in) the source. Since PHP can not fully parse the code, it can also not run your error handler on this error.
If You're forced to test if syntax is correct, You can use php_check_syntax function, with filename parameter PHP Manual php_check_syntax
php_check_syntax also provides second parameter, witch when used will be populated by the error string, as far as i remember
That's indeed terrible way of error logging
You don't need not a single advantage of a database. Would you make a database lookup for the certain line number? Or order your results by file name?
database is a subject of many errors itself.
You've been told already that it's impossible to catch a parse error at the program logic level, because a syntactically wrong program will never run.
Let's take your code as an example. It will raise a MySQL error (because of poorly formed query) which you will never see. As well as any other errors occurred. That's what I am talking about.