创建5个用户并设置8位随机密码
#!/bin/bash . /etc/init.d/functions for i in `seq 5`;do PASS=`echo $(date +%t%N)$RANDOM |md5sum |cut -c 1-8` useradd freddy$i >&/dev/null && USER_STATUS=$? echo "$PASS" | passwd freddy$i --stdin >&/dev/null && PASS_STATUS=$? if [ $USER_STATUS -eq 0 -a $PASS_STATUS -eq 0 ];then action "Useradd freddy$i OK" /bin/true echo -e "USER:freddy$i PASS:$PASS" >>/tmp/test/user.txt else action "Useradd freddy$i Fail" /bin/false echo "User freddy$i Create Fail.">>/tmp/test/user.txt fi done