Advertisement
systox

sendfile

May 24th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. local args = {...}
  2.  
  3. rednet.open("top")
  4.  
  5. term.clear()
  6. term.setCursorPos(1,1)
  7.  
  8. if #args < 1 then
  9. print("Usage (<> Reqired, [] Optional:")
  10. print("sendfile [ComputerID] <File>")
  11. return
  12. end
  13.  
  14. if #args == 1 then
  15. if fs.exists(args[1]) then
  16. textutils.slowPrint("Sending File "..args[1].."!")
  17. rednet.broadcast("RECEIVE")
  18. rednet.broadcast(args[1])
  19. file = fs.open(args[1], "r")
  20. rednet.broadcast(file.readAll())
  21. file.close()
  22. else
  23. print(args[1].." does not exists")
  24. return
  25. end
  26. else
  27. if fs.exists(args[2]) then
  28. textutils.slowPrint("Sending file "..args[2].." to "..args[1])
  29. F = rs.open(args[2], "r")
  30. id = tonumber(args[1])
  31. rednet.send(id, "RECEIVE")
  32. rednet.send(id, args[2])
  33. rednet.send(id, F.readAll)
  34. F.close()
  35. else
  36. print(args[2].." does not exists")
  37. return
  38. end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement