Martin
Martin

Reputation: 27

Lua: forward output from Minicom

I have a Lua script and in there I open a minicom session which executes a script (with the -S" parameter).

local myFile = assert(io.popen('minicom -S myScript.sh ' myDevice ' -C myLogFile.log'))
local myFileOutput = myFile:read('*all')
myFile:close()

This works really fine.

But I would like to get the same output as if I execute the minicom command itself:

minicom -S myScript.sh ' myDevice ' -C myLogFile.log

Right now I don't get any output at all (I know that that's somehow obvious).

I would that the output should also occur at (at least nearly) the same time as with the minicom command itself. Not one big chuck of data at the end.

Does anyone know how to achieve that?

Upvotes: 0

Views: 116

Answers (1)

Dmitry Meyer
Dmitry Meyer

Reputation: 1535

If I understand you correctly, you need something like

local myFile = assert(io.popen('minicom ...'))
for line in myFile:lines('l') do
  print(line)
end
myFile:close()

Upvotes: 1

Related Questions