This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

LUA API to get Wireshark installation info

0

Is there any LUA API available through which i can get information like where Wireshark is installed in my machine, Which version of wireshark installed etc. from registry or from anwhere? I need it because i have developed my own plugin in lua and i am using wireshark installed path upto C:\ProgramFiles\Wireshark in to that plugin.

asked 07 Jul '15, 20:41

ankit's gravatar image

ankit
65232328
accept rate: 25%

information like where Wireshark is installed in my machine

I.e., you want the installation directory of Wireshark? What would your Lua plugin use this for?

(07 Jul '15, 22:22) Guy Harris ♦♦

One Answer:

0

The Wireshark version you can get through the global function "get_version()", documented in the Utility functions section of the API docs.

I don't believe there's a way to get the Wireshark path directly/only, but it's likely the first portion of the string returned with the global function "Dir.global_config_path()" or "Dir.global_plugins_path()", as documented in the Directory functions section of the API docs. (I don't use Windows so I'm not sure it's the same directory, but you can try it and find out)

But why do you need the path exactly? I ask because if there's some good reason, then we can add it into the Lua API. Usually, though, people don't need it for Lua plugins.

answered 07 Jul '15, 22:22

Hadriel's gravatar image

Hadriel
2.7k2939
accept rate: 18%

I developed my whole plugin in structured way grouped some files into some folders and to traverse that folders i added dofile("path_to_wireshark_folder.."myfile.lua") in my_plugin_main.lua file. It is working fine with my environment. because i have manually given path_to_wireshark_folder = "C:\ProgramFiles\Wireshark" in my_plugin_main.lua

But Now, I need to generalize this plugin so that it can run in any person's machine and todo that i need the wireshark installation path where wireshark is installed into other person's enviornment.

(07 Jul '15, 22:57) ankit

You shouldn't need to do that.

Are they Lua modules? Or are they stand-alone scripts?

How are you loading your main Lua file? Through dofile(), or by having it in the personal plugins directory? Generally I recommend not using dofile(), and just putting your script in the personal plugins directory instead. That's where your new folder should be placed as well.

(07 Jul '15, 23:39) Hadriel

it is foolish to ask but i am unable to use existing global functions.I tried to use as mentioned in below image and I am getting error like "attempt to index global 'Dir'(nil value) If something is wrong can anyone tell me how to use global functions?

(08 Jul '15, 00:05) ankit

It's not a global function of Lua the language - it's a global function within Wireshark's Lua environment. So using ZeroBraneStudio to run the Lua script won't work.

(08 Jul '15, 07:16) Hadriel

I suppose I should mention this requires running Wireshark 1.12.x or 1.99.x. The Dir stuff was added in 1.11.3, as mentioned in the API docs.

(08 Jul '15, 09:48) Hadriel

my main.lua file is under C:\ProgramFiles\Wireshark\plugin\1.12.6\ directory and my code is under C:\Programfiles\Wireshark\MYLUA ... under MYLUA folder there are some subfolder into which there are some lua scripts so to call this scripts from my_main.lua i did dofile(...)

and as you suggested for Dir.global_config_path() It is working fine. thanks @hadriel

(09 Jul '15, 01:55) ankit
showing 5 of 6 show 1 more comments