Advertisement
Guest User

Untitled

a guest
Jun 8th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. function upload()
  2. file = fs.open(up,"r")
  3. text = file.readAll()
  4. file.close()
  5. rednet.send(id,"file upload "..fn)
  6. rednet.send(id,text)
  7. rednet.send(id,name)
  8. rednet.send(id,pass)
  9. mainshell()
  10. end
  11.  
  12. function download()
  13. rednet.send(id,"file download "..fn)
  14. rednet.send(id,"nil")
  15. rednet.send(id,name)
  16. rednet.send(id,pass)
  17. idc,text,weg = rednet.receive()
  18. file = fs.open(pa,"w")
  19. file.write(text)
  20. file.close()
  21. mainshell()
  22. end
  23.  
  24. function list()
  25. rednet.send(id,"file list")
  26. rednet.send(id,"nil")
  27. rednet.send(id,name)
  28. rednet.send(id,pass)
  29. idc,text,weg = rednet.receive()
  30. print(text)
  31. mainshell()
  32. end
  33.  
  34. function delete()
  35. rednet.send(id,"file delete "..del)
  36. rednet.send(id,"nil")
  37. rednet.send(id,name)
  38. rednet.send(id,pass)
  39. mainshell()
  40. end
  41.  
  42. function mainshell()
  43. write("OwncloudFile> ")
  44. sh = read()
  45. if sh == "upload" then
  46. print("Select file to upload")
  47. write("Upload> ")
  48. up = read()
  49. print("Name in Owncloud")
  50. write("Name> ")
  51. fn = read()
  52. upload()
  53. elseif sh == "download" then
  54. print("Select the File to download")
  55. write("Download> ")
  56. dow = read()
  57. print("Select path to save the file")
  58. write("Save> ")
  59. pa = read()
  60. download()
  61. elseif sh == "list" then
  62. list()
  63. elseif sh == "delete" then
  64. print("What File do you want to delete?")
  65. write("Delete> ")
  66. del = read()
  67. delete()
  68. elseif sh == "help" then
  69. print("upload to upload a file")
  70. print("download to download a file")
  71. print("list to list all files in your cloud")
  72. print("delete to delete a file in your cloud")
  73. print("exit to close the program")
  74. print("ver to see the version of the program")
  75. mainshell()
  76. elseif sh == "ver" then
  77. print("Version 1.0.0")
  78. mainshell()
  79. elseif sh == "exit" then
  80. exit = 1
  81. else
  82. print("Unknown command. Enter help to see all commands")
  83. mainshell()
  84. end
  85. end
  86.  
  87. write("Please enter the ID of your Owncloud Server:")
  88. idr = read()
  89. write("Please enter your username:")
  90. name = read()
  91. write("Please enter your password:")
  92. pass = read("*")
  93. write("Please enter the side of your Modem:")
  94. modem = read()
  95. rednet.open(modem)
  96. id = tonumber(idr)
  97. rednet.send(id,"logintest")
  98. rednet.send(id,"nil")
  99. rednet.send(id,name)
  100. rednet.send(id,pass)
  101. id,con,weg = rednet.receive(4)
  102. if con == nil then
  103. print("Can't connect to "..idr..". Are you sure, that Owncloud is running on this computer?")
  104. elseif con == "Wrong login" then
  105. print("Login failed. If you don't know your login, try as root as user and password")
  106. else
  107. mainshell()
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement