Guest User

Untitled

a guest
Sep 4th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. while read line;
  2. do
  3. fieldnumbers=$(echo $line | grep - o " " | wc - l)
  4. username=$(echo $line | cut -d' ' -f 1)
  5. home=$(echo $line | cut -d' ' -f 2)
  6. firstname=$(echo $line | cut -d' ' -f 3)
  7.  
  8. if [[ "$fieldnumbers" -eq b4 ]]
  9. then
  10. middlename=""
  11. else
  12. middlename=$(echo $line | rev | cut -d' ' -f 2)
  13.  
  14. lastname=$(echo $line | rev | cut -d' ' -f 1)
  15. password=$(echo pwgen 7 1) #create random password
  16. fullname="$firstname $middlename $lastname"
  17.  
  18. echo "username is : $username"
  19. sudo adduser --gecos $fullname --disabled-password --home $home $username
  20.  
  21. echo 'username:$password' | chpasswd
  22. echo 'Password is for $username is: $password"
Add Comment
Please, Sign In to add comment