[ubuntu-it] Re: Bash ed Useradd
Alessio
alessio.fattorini at gmail.com
Thu May 19 11:08:00 CDT 2005
Se può interessare alla fine ho usao expect ;)
#!/bin/bash
username=$1
password=$2
cat > /tmp/addpass << EOM
#!/usr/bin/expect -f
#
spawn bash
sleep 2
expect "# "
send "useradd -g 1000 -m -s /bin/true $username\r"
expect "# "
sleep 2
send "passwd $username\r"
expect "Enter new UNIX password: "
sleep 2
send "$password\r"
expect "Retype new UNIX password: "
sleep 2
send "$password\r"
expect "# "
exit
EOM
chmod 777 /tmp/addpass
/tmp/addpass > /dev/null
More information about the ubuntu-it
mailing list