a guest Sep 4th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- while read line;
- fieldnumbers=$(echo $line | grep - o " " | wc - l)
- username=$(echo $line | cut -d' ' -f 1)
- home=$(echo $line | cut -d' ' -f 2)
- firstname=$(echo $line | cut -d' ' -f 3)
- if [[ "$fieldnumbers" -eq b4 ]]
- middlename=$(echo $line | rev | cut -d' ' -f 2)
- lastname=$(echo $line | rev | cut -d' ' -f 1)
- password=$(echo pwgen 7 1) #create random password
- fullname="$firstname $middlename $lastname"
- echo "username is : $username"
- sudo adduser --gecos $fullname --disabled-password --home $home $username
- echo 'username:$password' | chpasswd
- echo 'Password is for $username is: $password"
RAW Paste Data