SHARE
TWEET

Untitled

a guest Sep 4th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top