#! /bin/bash
[ "$#" -lt "2" ]&&{
echo "please input userfile and password file after scritps"
exit 1
}
[ ! -e "$1" ]&&{
echo "$1 is not exit!!"
exit 1
}
[ ! -e "$2" ]&&{
echo "$2 is not exit!!"
exit 1
}
user=`awk 'END{print NR}'$1`
passwd=`awk 'END{print NR}'$2`
if [ $user != $passwd ];then
echo "userfile's line is diff passfile"
else
exit 1
fi
for num in `seq 1 $user`
do
USER=`sed -n ${num}p $1`
PASS=`sed -n ${num}p $2`
useradd $USER
echo $PASS|passwd --stdin $USER
else
echo "user1 is not exist"
done
if [ `whoami` = "root" ];then
echo "root"
else
echo "exec with root"
fi