2

I am trying to read the stdout of a simple python script

    import time
    while True:
        print("test")
        time.sleep(1)

with the following lua code

    local p = assert(io.popen("/usr/bin/python test.py", "r"))
    if not p then
        print("error")
    end
    print("process: "..tostring(p))

    while p do
        local line = p:read("*l")
        if line then
            print("line: "..tostring(line))
        end
    end

This prints a process file identifier but no output.

Substituting yes as command shows that the lua code in itself should work. However no method of calling the python script (including shebang) will produce any output. Changing to sys.stdout.write("test" + "\n") doesn't make a difference either.

I tried it on two machines running archlinux and debian. The first one is running python 3.7.2 and lua 5.3.5.

0 Answers0