Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function upload()
- file = fs.open(up,"r")
- text = file.readAll()
- file.close()
- rednet.send(id,"file upload "..fn)
- rednet.send(id,text)
- rednet.send(id,name)
- rednet.send(id,pass)
- mainshell()
- end
- function download()
- rednet.send(id,"file download "..fn)
- rednet.send(id,"nil")
- rednet.send(id,name)
- rednet.send(id,pass)
- idc,text,weg = rednet.receive()
- file = fs.open(pa,"w")
- file.write(text)
- file.close()
- mainshell()
- end
- function list()
- rednet.send(id,"file list")
- rednet.send(id,"nil")
- rednet.send(id,name)
- rednet.send(id,pass)
- idc,text,weg = rednet.receive()
- print(text)
- mainshell()
- end
- function delete()
- rednet.send(id,"file delete "..del)
- rednet.send(id,"nil")
- rednet.send(id,name)
- rednet.send(id,pass)
- mainshell()
- end
- function mainshell()
- write("OwncloudFile> ")
- sh = read()
- if sh == "upload" then
- print("Select file to upload")
- write("Upload> ")
- up = read()
- print("Name in Owncloud")
- write("Name> ")
- fn = read()
- upload()
- elseif sh == "download" then
- print("Select the File to download")
- write("Download> ")
- dow = read()
- print("Select path to save the file")
- write("Save> ")
- pa = read()
- download()
- elseif sh == "list" then
- list()
- elseif sh == "delete" then
- print("What File do you want to delete?")
- write("Delete> ")
- del = read()
- delete()
- elseif sh == "help" then
- print("upload to upload a file")
- print("download to download a file")
- print("list to list all files in your cloud")
- print("delete to delete a file in your cloud")
- print("exit to close the program")
- print("ver to see the version of the program")
- mainshell()
- elseif sh == "ver" then
- print("Version 1.0.0")
- mainshell()
- elseif sh == "exit" then
- exit = 1
- else
- print("Unknown command. Enter help to see all commands")
- mainshell()
- end
- end
- write("Please enter the ID of your Owncloud Server:")
- idr = read()
- write("Please enter your username:")
- name = read()
- write("Please enter your password:")
- pass = read("*")
- write("Please enter the side of your Modem:")
- modem = read()
- rednet.open(modem)
- id = tonumber(idr)
- rednet.send(id,"logintest")
- rednet.send(id,"nil")
- rednet.send(id,name)
- rednet.send(id,pass)
- id,con,weg = rednet.receive(4)
- if con == nil then
- print("Can't connect to "..idr..". Are you sure, that Owncloud is running on this computer?")
- elseif con == "Wrong login" then
- print("Login failed. If you don't know your login, try as root as user and password")
- else
- mainshell()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement