Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Developer's Notes: It was fun trying to break the program! Anyway, this
- is based on Egor305's FileServ, I just made it better, and added around 30
- more lines.]] for _, s in pairs(rs.getSides()) do if
- peripheral.isPresent(s) and peripheral.getType(s) == "modem" then
- rednet.open(s) end end local serverid = 27 --change! local id, msg local
- args={...} local program = "client" --change! local function get() repeat
- id,msg = rednet.receive(5) until id == serverid or id == nil print(msg
- or error("Cannot Reach Server",0)) end
- if #args < 1 or #args > 4 then
- print("\nDropX Usage:\n")
- print(program.." put <local_file>")
- print(program.." get [id] <server_file> <local_name>")
- print(program.." dir [id]")
- print(program.." del <server_file>")
- print("Made by: willwac")
- return
- end
- if args[1] == "send" or args[1] == "put" then
- if 1>#args or #args>3 then
- print("Usage:\n "..program.." put <local_file>")
- return
- end
- if not fs.exists(shell.resolve(args[2])) or fs.isDir(shell.resolve(args[2])) then
- printError("No such file!")
- return
- end
- theirFile=fs.open(shell.resolve(args[2]),"r")
- if not args[3] then args[3] = args[2] end
- rednet.send(serverid,"@put~!DSX!~"..args[3].."~!DSX!~"..theirFile.readAll())
- theirFile.close()
- get()
- elseif args[1] == "get" then
- if #args == 3 then
- args[4] = args[3]
- args[3] = args[2]
- args[2] = os.getComputerID()
- end
- if #args < 3 then
- print("Usage:\n "..program.." get [id] <server_file> <local_name>")
- return
- end
- rednet.send(serverid,"@get~!DSX!~"..args[2].."~!DSX!~"..args[3])
- repeat
- id,msg = rednet.receive(5)
- until id == serverid or id == nil
- if not id or not msg then error("Cannot Reach Server",0) end
- theirFile=fs.open(args[4],"w")
- if not theirFile then error("Could not open "..args[4].."! Try rebooting the computer.",0) end
- theirFile.write(msg)
- theirFile.close()
- print("Saved to: "..args[4])
- elseif args[1] == "dir" or args[1] == "list" or args[1] == "ls" then
- if #args > 2 then
- print("Usage:\n "..program.." dir [id]")
- return
- end
- if args[2] then
- rednet.send(serverid,"@list~!DSX!~"..args[2])
- else
- rednet.send(serverid,"@list~!DSX!~")
- end
- repeat
- id,msg = rednet.receive(5)
- until id == serverid or id == nil
- if id == nil then print("Cannot Reach Server") return end
- textutils.pagedTabulate(textutils.unserialize(msg))
- elseif args[1] == "del" or args[1] == "delete" then
- if #args > 2 or #args==1 then
- print("Usage:\n "..program.." del <server_file>\nNote: Cannot delete multiple files.")
- return
- end
- rednet.send(serverid,"@delete~!DSX!~"..args[2])
- get()
- else
- print("DropX Usage:")
- print(program.." put <local_file>")
- print(program.." get [id] <server_file> <local_name>")
- print(program.." dir [id]")
- print(program.." del <server_file>")
- print("Made by: willwac")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement