#!/bin/bash
#load system functions
[ -f /etc/init.d/functions ] && . /etc/init.d/functions
fori in`seq -w 10`
do
#generate passwd,8random chars
passwd=`echo $(date +%t%N)$RANDOM|md5sum|cut -c 2-9`
#check wheather the username isinthe /etc/passwd
#important awk usethe shell variable
check=`awk -F ':''/^'gccmx$i'/ {print $1}'/etc/passwd`
if[ -z "$check"];then
useradd gccmx$i &>/dev/null&& user_status=$?
echo $passwd | passwd --stdin gccmx$i &>/dev/null&& passwd_status=$?
else
user_status=1
passwd_status=1
fi
if[ "$user_status"-eq 0-a "$passwd_status"-eq 0];then
action "The user gccmx$i is add successfully!"/bin/true
echo -e "username:gccmx${i}\tpassword:${passwd}">>/tmp/userinfo.txt
else
action "The user gccmx$i is add faild!"/bin/false
echo -e "username:gccmx${i}\tpassword:${passwd}">>/tmp/faild_info.txt
fi
unset user_status && unset passwd_status
sleep 1
done
(责任编辑:IT) |

