Guest User

Untitled

a guest
Jan 31st, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. require 'io/console'
  3. def do_create_user(no,us,pw)
  4. pwd = pw.crypt("$5$a1")
  5. 1.upto(no) do | x |
  6. uname = us + x.to_s
  7. result = system("useradd -m -p '#{ pwd }' #{ uname }")
  8. if result
  9. puts "#{ uname } created!"
  10. else
  11. puts "#{ uname } failed!"
  12. end
  13. end
  14. end
  15.  
  16. print "How many users do you want? "
  17. count = gets.chomp.to_i
  18. print "Enter the username suffix, user, u etc... "
  19. user = gets.chomp.downcase
  20. print "Enter Password: "
  21. password = STDIN.noecho(&:gets).chomp
  22. puts "" # print an empty line
  23. do_create_user(count,user,password)
Add Comment
Please, Sign In to add comment