#! /bin/bash # run as su # Read from userpass.15.dat to add the listed users with predefined password via adduser for a Rocks clusters. for i in $(cat userpass.15.dat | awk '{print $2 , $3}') do #echo $i ti=$(echo "${i}" | cut -c1-1) re='^[0-9]+$' if ! [[ $ti =~ $re ]] ; then j=$(( $j + 1 )) username[$j]=$i # echo $j 'username[$j]=' ${username[$j]} fi if [[ $ti =~ $re ]] ; then passwd[$j]=$i # echo $j 'passwd[$j]=' ${passwd[$j]} fi done last=$(cat userpass.15.dat | awk 'END {print NR}') for (( i=1; i<=$last; i++ )) do echo ' ' echo $i passwd=${passwd[$i]} username=${username[$i]} adduser -m $username echo $username $passwd passwd $username usermod -g users $username echo ' ' done