1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-09 03:48:07 +11:00
OC-Minitel/FRequest/OpenOS/usr/bin/fget.lua

31 lines
624 B
Lua
Raw Normal View History

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]
local port = 70
2018-03-07 18:03:23 +11:00
local host,nport = host:match("(.+):(%d+)")
port = nport or port
host = host or address
local socket = net.open(host,port)
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
repeat
l = socket:read(1024)
io.write(l)
os.sleep(0.5)
until socket.state == "closed" and l == ""