Quipex

Disk/mem/redworks/programs/adduser

Apr 23rd, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. local sPasswdPath = "ACCOUNTS.F"
  2. params = { ... }
  3. if #params < 2 then
  4. error( "Usage: adduser <username> <password>" )
  5. end
  6. local tPasswd = { }
  7.  
  8. if fs.exists( sPasswdPath ) then
  9. print("File exists. Loading")
  10. local file = io.open(sPasswdPath)
  11. local sLine = file:read()
  12. while sLine do
  13. for k, v in string.gmatch(sLine, "(%w+)%s(%w+)") do
  14. tPasswd[k]=v
  15. end
  16. sLine = file:read()
  17. end
  18. file:close()
  19. end
  20.  
  21. tPasswd[params[1]]=params[2]
  22.  
  23. local file = io.open(sPasswdPath,"w")
  24. for user,pass in pairs(tPasswd) do
  25. file:write(user .. " " .. pass .."\n")
  26. end
  27. file:close()
  28. print("User " .. params[1] .. " has been created.")
Add Comment
Please, Sign In to add comment