Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --start up
- peripheral.find("modem", rednet.open)
- rednet.host("fileServer","fileServer1ed ")
- if fs.isDir("os/programs") == false then
- fs.makeDir"os/programs"
- end
- local programList = fs.list("os/programs")
- while true do
- local id, msg = rednet.receive("fileServer")
- if msg[1] == "filelist" then
- rednet.send(id, programList)
- print("computer-"..id..": asked for filelist")
- elseif msg[1] == "request" then
- print("computer - "..id..": asked for file > "..msg[2])
- local file = fs.open("os/programs/"..msg[2], "r")
- local contents = file.readAll()
- rednet.send(id, contents)
- file.close()
- else
- rednet.send(id,"invalid request")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement