From: Angel Alejandro Vega Soto (alejandro.vega@tecinfocon.com.mx)
Date: Thu Sep 29 2005 - 12:20:47 EDT
thanks to ian.mcgingley at axa-tech.com.au from actually sending a
script, and giving me some ideas.
NOTE: puting all the password in a spreadsheet is a great securuty risk,
and has been noticed.
the solution is divided in two parts
1.- the spreadsheet must be saved in a csv file (coma separated values,
without double quotes " )
2.- two scripts, 1 in shell to get the useradd bin working and another
using expect to get the password.
here are the two scripts.
put_passwd.expect
#!/opt/sfw/bin/expect
if $argc<2 {
send_user "$argv0: missing parameters\n"
exit }
set username [lindex $argv 0 ]
set password [lindex $argv 1 ]
spawn passwd $username
expect "ew Password:"
send "$password\r"
expect "ew Password:"
send "$password\r"
expect "#"
exit
the putuser.sh which call the first one.
#!/bin/bash
FILEIN=$1
SGID=100
USERSHOME=/export/home/users
USERSSHELL=/bin/false
USRCRTLOG=/var/log/usercreation.log
IFS=,
cat $FILEIN | while read internalvalue comentario password userid
anotherdata
do
useradd -g $GID -c "$comentario $internalvalue " -d
$USERSHOME/$userid -s $USERSSHELL -m -k /etc/skel $userid 2> $USRCRTLOG
./put_passwd.expect $userid $password 2>> /var/log/useradd.log
done
-- Ing. Cngel Alejandro Vega Soto (52)55-23-19-75 TecnologC-a InformC!tica y ConsultorC-a (52)53-36-95-28 alejandro.vega@tecinfocon.com.mx http://www.tecinfocon.com.mx Gerente de Servicio, Solaris - Linux, Software and protocols specialist _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagers
This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:31:54 EDT