How can I pass arguments (from the command line) to a tshark/Lua script?
Specifically, I'm interested in having a DEBUG flag, that changes the script's logics.

asked 07 Dec '11, 07:51

Trevor's gravatar image

Trevor
26447
accept rate: 0%

edited 07 Dec '11, 07:52


I recently learned how to make lua scripts for tshark. I believe I recall seeing in passing that passing args from command line to script cannot be done at this time. I don't recall where that was though.

link

answered 07 Dec '11, 13:19

studog's gravatar image

studog
16224
accept rate: 0%

Someone had asked this a while ago on one of the mailing lists...

The only way (AFAIK) to pass arguments to a WS Lua script is to use environment variables, as shown here:

$ echo "print('DEBUG', os.getenv('DEBUG'))" > test.lua
$ DEBUG=1 tshark -v -Xlua_script:test.lua 
DEBUG   1
TShark 1.7.1 (SVN Rev 39998 from /trunk)

Copyright 1998-2011 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiled (64-bit) with GLib 2.28.8, with libpcap 1.1.1, with libz 1.2.5, without
POSIX capabilities, with SMI 0.4.8, with c-ares 1.7.4, with Lua 5.1, with Python
2.7.1, with GnuTLS 2.8.6, with Gcrypt 1.5.0, with MIT Kerberos, with GeoIP.

Running on Mac OS 10.7.2 (Darwin 11.2.0), with locale en_US.UTF-8, with libpcap
version 1.1.1, with libz 1.2.5.

Built using llvm-gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build
2336.1.00).
link

answered 07 Dec '11, 13:27

helloworld's gravatar image

helloworld
2.6k21739
accept rate: 27%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×246
×121

Asked: 07 Dec '11, 07:51

Seen: 1,247 times

Last updated: 07 Dec '11, 13:27

powered by OSQA