valis

Untitled

Apr 5th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.23 KB | None | 0 0
  1. #useradd script
  2.  
  3. DECISION=yes
  4. while [ "$DECISION" = 'yes' ]; do
  5.  
  6. echo Please Enter First Name
  7. read FNAME
  8. echo Please Enter Last Name
  9. read LNAME
  10.  
  11. #variables for comment field
  12.  
  13. UFNAME=`echo $FNAME | cut -c 1 | tr [:lower:] [:upper:]`
  14. LFNAME=`echo $FNAME | cut -c 2- | tr [:upper:] [:lower:]`
  15. ULNAME=`echo $LNAME | cut -c 1 | tr [:lower:] [:upper:]`
  16. LLNAME=`echo $LNAME | cut -c 2- | tr [:upper:] [:lower:]`
  17.  
  18. #variables for username
  19.  
  20. USRNM=`echo $LNAME$FNAME | tr [:upper:] [:lower:]`
  21.  
  22. echo Please Enter Department
  23. read DEPT
  24.  
  25. #variable for naming department
  26.  
  27. NDEPT=`echo $DEPT | cut -c -4 | tr [:upper:] [:lower:]`
  28.  
  29. groupadd $NDEPT
  30.  
  31. useradd -c "$ULNAME$LLNAME, $UFNAME$LFNAME" -g $NDEPT -G users $USRNM
  32. echo 123456 | passwd --stdin $USRNM
  33.  
  34. echo "Would you like to add another user?(yes/no)"
  35. read YESNO
  36.  
  37. DECISION=`echo $YESNO | tr [:upper:] [:lower:]`
  38. DONE
  39.  
  40. LOOP=1
  41. while [ "$DONELOOP" -eq "1" ] do
  42.     if [ $DECISION == "yes" ]; then
  43.         DECISION=yes
  44.             DONE
  45.  
  46. LOOP=2
  47.                 elif [ "$DECISION" == "no" ]; then
  48.                     echo "Thank you for using this program"
  49.                         DONE
  50.  
  51. LOOP=2
  52.                         else
  53.                     echo "Please use a correct option. (yes/no)"
  54.                 read YESNO
  55.             DECISION=`echo $YESNO | tr [:upper:] [:lower:]`
  56.         fi
  57.     done
  58. done
Advertisement
Add Comment
Please, Sign In to add comment