Advertisement
asteroidsteam

sudo

Oct 29th, 2017
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. local tArgs = {...}
  2. function sudo(command)
  3.   fileP = fs.open("key", "r")
  4.   passwd = fileP.readAll()
  5.   fileP.close()
  6.   write("Enter Password: ")
  7.   password = read("*")
  8.   if (password == passwd) then
  9.     shell.run(command)
  10.   else
  11.     print("Incorrect password!")
  12.   end
  13. end
  14. function printUsage()
  15.   printError("----------PHUDO 1.0----------")
  16.   printError("Usage:")
  17.   printError("sudo <command> (args)")
  18.   printError("-----------------------------")
  19. end
  20. cmd = ""
  21. if (#tArgs == 0) then
  22.   printUsage()
  23. else
  24.   for i=1,#tArgs do
  25.     cmd = cmd.." "..tArgs[i]
  26.   end
  27.   sudo(cmd)
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement