Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --vars
- tbl = {}
- --functions
- function Init()
- rn = fs.open(".rnconfig", 'r')
- rednet.open(rn.readAll())
- if rednet.isOpen() then
- print("Rednet Open")
- return true
- else
- print("Rednet closed, contact systems manager to resolve")
- return false
- end
- end
- function Log(data1,data2,data3)
- local log = fs.open(".log", "a")
- log.writeLine(data1..data2,data3)
- log.close()
- end
- function getInput()
- print("Waiting:")
- local client, message, protocol = rednet.receive("ftp")
- Log(client, message, protocol)
- print(client..message..protocol)
- --analysis of data
- for i=0, #tbl do
- table.remove(tbl, i)
- end
- for w in string.gmatch(message, "%a+") do
- table.insert(tbl, w)
- end
- if tbl[1] == "getFile" then
- local gFile = fs.open(tbl[2], "r")
- rednet.send(client, gFile.readAll(), "ftp")
- gFile.close()
- elseif tbl[1] == "sendFile" then
- local sFile = fs.open(tbl[2], "w")
- local cli, data, prot = rednet.receive("ftp")
- sFile.write(data)
- sFile.close()
- end
- getInput()
- end
- --init sequence
- Init()
- term.clear()
- term.setCursorPos(1,1)
- getInput()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement