Hi all,
I've been trying to make a small bash script to create a user and then to switch to the new user. But, I cannot giving the password when the script executes the command
I'm trying this:
Code:
#!/bin/bash
user=test
pass=xxxx
dir=/var/www/mydir
group=adm
bash=/bin/bash
sudo useradd -d "$dir" -s "$bash" -g "$group" -m $user
echo "$user:$pass" |sudo chpasswd
echo -e "El usuario ha sido creado con exito...\n"
echo -e "$pass\n" | su - $user > /dev/null 2>&1 && echo -e "\nSwitching user completed... You're $user"
# ??????
I need switch user inside de bash script, but I don't know how... I hope you can help me...
Thanks in advance.