用户创建脚本

    xiaoxiao2021-03-25  151

    #!/bin/bash # echo -n "Input a username of file :" read file1 if [ -e $file1 ] then MAXLINE1=`wc -l $file1 |cut -d " " -f 1` else echo "No have username of file:" exit fi echo -n "Input a passwd fo file :" read file2 if [ -e $file2 ] then MAXLINE2=`wc -l $file1 |cut -d " " -f 1` else echo "No have username of file:" exit fi if [ $MAXLINE1 -eq $MAXLINE2 ] then for NUM in $( seq 1 $MAXLINE1) do USERNAME=`sed -n ${NUM}p $file1` PASSWORD=`sed -n ${NUM}p $file2` id $USERNAME >& /dev/null if [ $? -ne 0 ] then useradd $USERNAME echo $PASSWORD | passwd --stdin $USERNAME else echo "$USERNAME alredy exists" fi done else echo "A corresponding to different user and passwd " fi exit

     

    转载请注明原文地址: https://ju.6miu.com/read-24372.html

    最新回复(0)