DX Unified Infrastructure Management

 View Only
  • 1.  Debugging of Scripts e.g.Pre-Processing Scripts

    Posted Jan 19, 2010 03:43 PM
    Hi!

    A new day, a new question :-)
    Is it possible to have some debugging on LUA-Scripts ?
    In
    my case I have a Pre-Processing-Script, which should took an incomming
    message, check its bad readable contend and translate it into some more
    readable, there ist no filter or something afterwards, syntax is
    correct, but perhaps I have some logical error in it, and I did not get
    it at the moment.
    Even a full nas.logging-level doesnt ggave me something

    Cheers
    Matthias Gruber


  • 2.  Debugging of Scripts e.g.Pre-Processing Scripts

    Posted Jan 19, 2010 06:15 PM
    Matthias,

    Did the alarm message come through with its original text, or did it not come through at all?

    I usually use print() or nimbus.alarm() to generate debugging information in NAS scripts, but I most often work on scripts fired off by AO profiles or the scheduler.  I know pre-processing scripts are special.  I am fairly certain they do not have access to nimbus.alarm(), but they might have access to print().  Have you tried that?

    -Keith


  • 3.  Debugging of Scripts e.g.Pre-Processing Scripts

    Posted Jan 19, 2010 07:31 PM
    Keith,

    hmm...print(), where is the output be sended...and correct you dont have nimbus.alarm() in pre-pro. I did it now with event.message :-) and found the error.

    It is quite difficult if someone like me, who is an old python-coder (which relies on indenting for iteration and if-then-Stuff ), to work with lua, I simply forgot an end after a for-iteration and "for i,v in ipairs(foo) do" without an end seems to be a valid statement, quite anoying :-(. Sometimes lua remembers a lot like perl in case of readbillity and how to "shortcut", I could start a contest for the best unreadable code :-)

    Thanks a lot
    Matthias




  • 4.  Debugging of Scripts e.g.Pre-Processing Scripts

    Posted Jan 19, 2010 09:50 PM
    Hi!

    Concerning the "print" well I found it ;-), didnt thougt of the nas.logfile, so finally I can debug, I surely ran in the next problem, hmmm LUA and me still need some time to find together....

    Cheers
    Matthias


  • 5.  Debugging of Scripts e.g.Pre-Processing Scripts

    Posted Jan 20, 2010 06:01 PM
    Matthias,

    Thank you for confirming that the print() statements end up in the log.  I knew that was true when using them in AO profiles and schedules, but I was not sure about pre-processing rules.  I am glad you were able to locate your issue.

    Sometimes I edit Lua scripts in Vim, and I believe that highlights mismatched block start/end statements in red.  I am not sure if it would have helped you spot your issue sooner in this case or not.  I know Carstein usually recommends Crimson Editor, and I think he has made a Lua syntax highlighting configuration for it.  The script editor built into the NAS works well, but using a different editor might help with some of those other details.

    I think it is funny how previous programming experience can affect your learning curve with a new language.  I come from a mostly Perl background, so I am used to being able to refer to defined and undefined variables freely.  Lua enforces types much more than Perl, so it took me a while to get used to the situations when that matters.

    -Keith