I'm about to write a dissector for Wireshark in Lua but wanted to test a simple hello world first. But how do know it is running? Can I see the debug print somewhere? This is the script:
-- hello.lua
print("Hello World!")
I run Wireshark 0.99.7 on Windows.
There's a note on the wireshark Lua page saying:
Please note: On Windows, you may not see any output when running Lua scripts in Wireshark. If the console window is enabled it will be opened after the lua engine is loaded. This does not affect TShark, since it is a console program.
Maybe that's what you're seeing (or not for that matter).
For later use, you'll probably be using wiresharks Lua API functions like these functions
You can use debug(). If lua is working, you should see it in the console, which can be found in tools->lua->console.
Related
I would like to use the ipc server in mvp. It does exactly what I need. But from my app I can't talk to sockets using echo. Thats why I am thinking about lua scripts.
It seems that mpv autoload the lua scripts so they can be called by keystrokes o events.
How can I execute a lua script from the terminal and get a response if the script return something?
Just in case: in the end, I need to build something like json http responses in VLC.
I'm currently writing some dissector for Wireshark in Lua. The Lua code has become quite large. Because of that I'm splitting it up into multiple files (modules). I got that working. By the way my goal is that the user just needs to copy the files into the plugins directory so that the dissector is automatically loaded every time Wireshark is started.
Now, to gain access to the other files from the "main file" I need to do this:
package.prepend_path(".\plugins\3.3\modulesDir")
local mymodule= require "module"
This works fine, but it has some disadvantages. Most importantly if a user uses a different version of Wireshark I need to change the path in the Lua code. Same if it's a different directory (Linuy, Mac OS).
To get around this I did some research on how to get the path of the current Lua file and came up with this:
local moduleDir = debug.getinfo(2, "S").source:sub(2)
moduleDir = moduleDir:match("(.*[/\\])")
This works platform indepedently, so it looks to be the perfect solution for what I want. If I execute this using Wireshark > Tools > Lua > Evaluate it work perfectly fine.
BUT: If I do it in the Lua file (which is my dissector) then I get the error "attempt to index a nil value". I tried various different versions of this line but it always appears that the debug table is nil. I'm using Wireshark version 3.3.
Has anyone an idea how to get it running? Or a different approach to getting the directory where the Lua file is in? Thanks in advance.
If you are looking for "global configuration directory" then you can use Dir.global_config_path(). Here you have that init.lua is in this path, and here lua function dtails.
On Windows, I have my Lua files in the "Personal Lua Plugins" directory, which when you look at Wireshark's "Help -> About Wireshark -> Folders" dialog, is just %APPDATA%\Wireshark\plugins. So, perhaps you can just move your folder from path\to\plugins\3.3\modulesDir to just path\to\plugins\modulesDir?
I believe you will then only require:
package.prepend_path("modulesDir")
And this will allow your Lua dissector and modules to work not only with the Wireshark 3.3 development version, but also future releases as well. And if your dissector can't work with older versions of Wireshark for some reason, you can always do something like:
if get_version() < "3.3" then
return
end
Lastly, have a look at how Hadriel Kaplan solved this for his protobuf.lua dissector, where his required modules are in the "modules" directory. It's basically as I've described above. See: https://github.com/128technology/protobuf_dissector
I host a server and I was wondering: is there any way to run chat commands through ComputerCraft? I want to be able to run /tps through the ComputerCraft terminal and then have it print out the TPS. Help would be greatly appreciated.
Thanks.
In the new Computercraft 1.7 there is a new type of computer, the Command Computer. It allows the user to run commands the same way as shell.run("mkdir", "foo"). It can only be obtained by ops, and can only directly be controlled (we are talking without using rednet and such) by ops
commands.exec(string command) -- Runs and outputs command output in chat.
commands.execAsync(string command) -- Quietly runs command without output.
Here is the wiki page:
Commands (API)
But if we are talking 1.6.4 (Which almost all modpacks use) there is no "stock" version of doing that.
Hope it helps /Tyrerexus
I believe that you can use this thing called the Chat Box.
http://ftbwiki.org/Chat_Box
It's not part of the default Computercraft, however. It is part of the Misc Peripherals mod I believe.
I now know that I can't interact with Dart via the console, but I was hoping that there may be another way to invoke a REPL within Dartium.
Basically, what I would like to be able to do is:
1. Go to a website in Dartium
2. Invoke some sort of Dart REPL
3. Mess about with the DOM, CSS etc., using Dart commands, rather than Javascript.
Is this possible at all? Or, is the Dart development model all Edit/Refresh?
Cheers
Andy
Chrome Dev tools in Dartium will now let you do this very nicely.
Dart edit model is Edit/Refresh.
Maybe you are looking for something like http://try.dartlang.org/
I'm modifying a Firefox extension that has been written by someone else, and I'm not very experienced with Javascript and Firefox, so my question is probably fairly simple.
I have a lot of code in a Javascript Module (.jsm file), and I want to produce some outputs form this module to help with debugging. I can't seem to use javascript alerts (alert("blah");) or log to the javascript console (console.log("blah");) as both of these give errors saying that console or alert cannot be found.
Is there any way to produce this sort of debugging output from code running in a Javascript Module? All I want is simple text output to help with my development/debugging process.
There are two common options:
Use dump(), the output will be printed to OS console (on Windows you need to run Firefox with -console command line option to see it).
Use Component.utils.reportError, the output will be printed to Error Console - use Ctrl-Shift-J to open it.