0

Need help Required to convert below bash script in expect script.


#Script to Add User
tail /etc/passwd | cut -d: -f1
read -p 'Please Enter The Username To Add: ' name
echo "$name" > /tmp/userlist.txt
clear
echo -e "Hallo $name\nYour Name Is Added To The List."
userfile=/tmp/userlist.txt
username=$(cat /tmp/userlist.txt | tr 'A-Z' 'a-z')
for user in $username
do
useradd $user -N -s /bin/bash
usermod -aG sudo $user
passwd $user

sed -i "s/tui/tui $user/g" /etc/ssh/sshd_config
sed -i "s/$user.*$user/$user/g" /etc/ssh/sshd_config
sed -i "s/tui/tui $user/g" /etc/security/access.conf
done
echo "=================================="

echo "User $name Have Been Created."

echo "=================================="
tail /etc/passwd | cut -d: -f1

GauravG
  • 19
  • 7
  • Do you ***really*** plan on putting a default password in a script, so that everyone gets the ***same*** default password?!?!? – Andrew Henle Sep 17 '20 at 10:52
  • @Andrew : yes, I the requirement is same so can't help it. If you Wil mention password changing part that would be helpful as well. Thanks – GauravG Sep 17 '20 at 10:55

0 Answers0