Help for coding: Read from console and put into a file

classic Classic list List threaded Threaded
1 message Options
Whee Min TAN (NYP) Whee Min TAN (NYP)
Reply | Threaded
Open this post in threaded view
|

Help for coding: Read from console and put into a file

Hi! My router is pre-load with basic functions lua. I trying to read from console what I type and put it into a file in my router. The lua only have basic input/output functions like file:read,file:write,io:open, etc.It’s does not have rs232 or uart library.

 

I wrote the code below:

 

inp = assert(io.open(“/dev/ttyS1”,”r”)

out=assert(io.open(“rtest.txt”,”w”)

 

while true do

data=inp:read(“all”)

data=string:gsub(data, “\r\n”, “\n”)

out:write(data)

end

assert(out:close())

 

The above cannot work. Can anybody help and advise?

 

Tan


_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev