Wireshark-dev: Re: [Wireshark-dev] Getting a pcap filename from a Lua script
From: Tony Trinh <[email protected]>
Date: Sun, 15 Jan 2012 11:12:48 -0500
On Sun, Jan 15, 2012 at 6:34 AM, Maayan Zadik <[email protected]> wrote:

 

Is there a way to retrieve the capture file name from inside the Lua script, that way I can name the log: “<filename>_log”?



Someone asked about this a few months ago. No, the Lua API currently does not support this, but there might be other ways to accomplish the same goal:

1) Pass environment variable, containing the filename, to the Lua script

   echo "print('\$PCAP:', os.getenv('PCAP'))" > foo.lua
   PCAP=foo.pcap tshark -r foo.pcap -Xlua_script:foo.lua -q

2) Print to stdout from Lua, and redirect to file

   tshark -r foo.pcap -Xlua_script:foo.lua -q > foo.pcap.analysis.txt