用户建立脚本
#### 脚本需求如下:
- 执行users_create.sh userlist passlist
- 建立userlist列表中的用户
- 设定userlist列表中的密码为passlist列表中的密码
- 当脚本后面跟的文件个数不足两时,报错
- 当文件行数不一致时报错
- 当文件不存在时报错
- 当用户存在时报错
[root@westos137 mnt]# cat users_create.sh
#!/bin/bash
if [ "$#" -lt "2" ]
then
echo -e "\033[31mPlease input userfile or passfile following script! \033[0m"
exit
elif [ ! -e "$1" ]
then
echo -e "\033[31m$1 is not exist!\033[0m"
exit
elif [ ! -e "$2" ]
then
echo -e "\033[31m$2 is not exist!\033[0m"
exit
elif [ "`sed -n $= $1`" != "`sed -n $= $2`" ]
then
echo -e "\033[31m$1's line is different then $2!!\033[0m"
exit
else
LINE=1
for USERNAME in `cat $1`
do
id $USERNAME &> /dev/null &&{
echo -e "\033[31m$USERNAME is exist!\033[0m"
}||{
PASSWD=