Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Client Program
- local modemSide = "right" -- Adjust the side where your modem is connected
- local serverID
- -- Get the server ID from the user
- write("Enter Server ID: ")
- serverID = read()
- rednet.open(modemSide)
- while true do
- print("\nOptions:")
- print("1. List Files")
- print("2. Delete File")
- print("3. Move File")
- print("4. Copy File")
- print("5. Edit File")
- print("6. Exit")
- write("Select an option (1-6): ")
- local choice = tonumber(read())
- if choice == 1 then
- rednet.send(serverID, "list_files")
- local _, fileList = rednet.receive(serverID)
- local files = textutils.unserialize(fileList)
- print("\nFiles in /network directory:")
- for _, file in ipairs(files) do
- print("- " .. file)
- end
- elseif choice == 2 then
- write("Enter file name to delete: ")
- local fileName = read()
- rednet.send(serverID, "delete_file:" .. fileName)
- print("Deleting file...")
- elseif choice == 3 then
- write("Enter source file name: ")
- local source = read()
- write("Enter destination file name: ")
- local destination = read()
- rednet.send(serverID, "move_file:" .. source .. "," .. destination)
- print("Moving file...")
- elseif choice == 4 then
- write("Enter source file name: ")
- local source = read()
- write("Enter destination file name: ")
- local destination = read()
- rednet.send(serverID, "copy_file:" .. source .. "," .. destination)
- print("Copying file...")
- elseif choice == 5 then
- write("Enter file name to edit: ")
- local fileName = read()
- rednet.send(serverID, "edit_file:" .. fileName)
- print("Editing file...")
- elseif choice == 6 then
- print("Exiting program.")
- break
- else
- print("Invalid choice. Please enter a number between 1 and 6.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement