Advertisement
Guest User

scp.lua

a guest
Jun 12th, 2024
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. function help()
  2.     print("Usage: scp <target ID> <filename>")
  3. end
  4.  
  5. function main()
  6.  
  7. if #arg < 2 then
  8.     help()
  9.     return
  10. end
  11.  
  12. local target = arg[1]
  13. if not target then
  14.     help()
  15.     return
  16. end
  17.  
  18. local filename = arg[2]
  19. if not filename then
  20.     help()
  21.     return
  22. end
  23.  
  24. file = io.input(filename)
  25. cont = io.read("*all")
  26. local modem = peripheral.find("modem")
  27. if not modem then
  28.     error("no modem")
  29. end
  30. peripheral.find("modem", rednet.open)
  31.  
  32. print("Sending '".. filename .. "' to ID " .. target)
  33. rednet.send(tonumber(target), filename, "scp")
  34. rednet.send(tonumber(target), cont, "scp")
  35.  
  36. end
  37. main()
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement