2018-02-19 21:04:22 +11:00
|
|
|
local net = require "net"
|
|
|
|
local event = require "event"
|
|
|
|
|
|
|
|
local tArgs = {...}
|
2018-03-07 18:03:23 +11:00
|
|
|
local address, path = tArgs[1], tArgs[2]
|
2018-02-19 21:04:22 +11:00
|
|
|
local port = 70
|
|
|
|
|
2018-04-15 18:28:41 +10:00
|
|
|
local host,nport = address:match("(.+):(%d+)")
|
2018-03-07 18:03:23 +11:00
|
|
|
port = nport or port
|
|
|
|
host = host or address
|
2018-02-19 21:04:22 +11:00
|
|
|
|
2018-02-19 21:23:19 +11:00
|
|
|
local socket = net.open(host,port)
|
2018-02-19 22:49:23 +11:00
|
|
|
socket:write("t"..path.."\n")
|
|
|
|
local c = socket:read(1)
|
|
|
|
repeat
|
|
|
|
c = socket:read(1)
|
|
|
|
os.sleep(0.5)
|
|
|
|
until c ~= ""
|
|
|
|
if c == "n" then
|
|
|
|
print(path..": Not found.")
|
|
|
|
elseif c == "f" then
|
|
|
|
print("Failure: ")
|
|
|
|
elseif c == "d" then
|
|
|
|
print("Directory listing for "..path)
|
|
|
|
end
|
2018-02-19 21:04:22 +11:00
|
|
|
repeat
|
2018-02-19 21:23:19 +11:00
|
|
|
l = socket:read(1024)
|
2018-02-19 21:04:22 +11:00
|
|
|
io.write(l)
|
|
|
|
os.sleep(0.5)
|
2018-02-19 21:23:19 +11:00
|
|
|
until socket.state == "closed" and l == ""
|