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

I am trying to open a text file within my Lua script that is launched from Wireshark. However, it is not clear how to specify the filename as an absolute path or where the file should be stored.

local csv_file = assert(io.open("AP_Batch.csv", "r"))

When this executes I get "nil" back. I tried the following (with the same file copied into C:\temp)

local csv_file = assert(io.open("C:\Temp\AP_Batch.csv", "r"))

Where does Wireshark/Lua expect the current working directory to exist. I've copied the same file into Wireshark's installation folder, my home directory.

Could someone enlighten me what folder I should place the file or how to specify a full Windows style path.

EDIT: I tried C:\\Temp\\AP_Batch.csv, but this failed. The error dialog tells me "No such file of directory" and displays c:\Temp\AP_Batch.csv as what it tried to open

asked 14 May '15, 12:08

carlwain74's gravatar image

carlwain74
1334
accept rate: 0%

edited 14 May '15, 12:14


Some headway on this issue - File turned out to be named AP_Batch.csv.csv in Windows :-(

However, I would still like to know where Lua and Wireshark expect files to exist if no path is specified

permanent link

answered 14 May '15, 12:55

carlwain74's gravatar image

carlwain74
1334
accept rate: 0%

You can refer this lua file io

If no path is specified then io.open API bydefault takes that path where your .lua file is created for example if you have created sample.lua as below and you are trying to read test.lua from that

  1. --Opens a file in read
  2. file = io.open("test.lua", "r")
  3. -- sets the default input file as test.lua
  4. io.input(file)
  5. -- prints the first line of the file
  6. print(io.read())

then test.lua should be in that directory where your sample.lua is created and for the file which is in another directory you can define the path like io.open("D:\lua.txt,"r")

permanent link

answered 14 May '15, 21:15

ankit's gravatar image

ankit
65232328
accept rate: 25%

ok sample.lua is located in the Wireshark folder. I confirmed that without a path it opens the file in this location.

(15 May '15, 17:12) carlwain74
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

Question tags:

×431
×103
×1

question asked: 14 May '15, 12:08

question was seen: 3,900 times

last updated: 15 May '15, 17:12

p​o​w​e​r​e​d by O​S​Q​A