Advertisement
DOGGYWOOF

client - netowrk

Jan 21st, 2024 (edited)
3
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. -- Client Program
  2.  
  3. local modemSide = "right" -- Adjust the side where your modem is connected
  4. local serverID
  5.  
  6. -- Get the server ID from the user
  7. write("Enter Server ID: ")
  8. serverID = read()
  9.  
  10. rednet.open(modemSide)
  11.  
  12. while true do
  13. print("\nOptions:")
  14. print("1. List Files")
  15. print("2. Delete File")
  16. print("3. Move File")
  17. print("4. Copy File")
  18. print("5. Edit File")
  19. print("6. Exit")
  20.  
  21. write("Select an option (1-6): ")
  22. local choice = tonumber(read())
  23.  
  24. if choice == 1 then
  25. rednet.send(serverID, "list_files")
  26. local _, fileList = rednet.receive(serverID)
  27. local files = textutils.unserialize(fileList)
  28.  
  29. print("\nFiles in /network directory:")
  30. for _, file in ipairs(files) do
  31. print("- " .. file)
  32. end
  33.  
  34. elseif choice == 2 then
  35. write("Enter file name to delete: ")
  36. local fileName = read()
  37. rednet.send(serverID, "delete_file:" .. fileName)
  38. print("Deleting file...")
  39.  
  40. elseif choice == 3 then
  41. write("Enter source file name: ")
  42. local source = read()
  43. write("Enter destination file name: ")
  44. local destination = read()
  45. rednet.send(serverID, "move_file:" .. source .. "," .. destination)
  46. print("Moving file...")
  47.  
  48. elseif choice == 4 then
  49. write("Enter source file name: ")
  50. local source = read()
  51. write("Enter destination file name: ")
  52. local destination = read()
  53. rednet.send(serverID, "copy_file:" .. source .. "," .. destination)
  54. print("Copying file...")
  55.  
  56. elseif choice == 5 then
  57. write("Enter file name to edit: ")
  58. local fileName = read()
  59. rednet.send(serverID, "edit_file:" .. fileName)
  60. print("Editing file...")
  61.  
  62. elseif choice == 6 then
  63. print("Exiting program.")
  64. break
  65.  
  66. else
  67. print("Invalid choice. Please enter a number between 1 and 6.")
  68. end
  69. end
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement