[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Right way to emty stdin?
- From: Gilles Ganault <gilles.ganault@...>
- Date: Wed, 23 Feb 2011 13:48:12 +0100
Hello
I'm having a problem reading whatever data a server is sending to
the script through stdin.
This code is based on what I read in the www.lua.org/pil/21.1.html
page:
=======
#!/usr/bin/lua
--Must first empty stdin
while true do
local line = io.read()
-- if line == "" then break end
if line == nil then break end
end
io.write("NOOP After loop\n")
line = io.read()
=======
For some reason, the script seems stuck in the while loop, since it
never displays the NOOP line.
"luac -p myscript.lua" doesn't return an error.
Any idea what could be wrong with the code?
Thank you.