shell - Syntax error: “(” unexpected (expecting “fi”) -
filein="users.csv" ifs=$'\n' if [ ! -f "$filein" ] echo "cannot find file $filein" else #... groups=(`cut -d: -f 6 "$filein" | sed 's/ //'`) fullnames=(`cut -d: -f 1 "$filein"`) userid=(`cut -d: -f 2 "$filein"`) usernames=(`cut -d: -f 1 "$filein" | tr [a-z] [a-z] | awk '{print substr($1,1,1) $2}'`) #... group in ${groups[*]} grep -q "^$group" /etc/group ; let x=$? if [ $x -eq 1 ] groupadd "$group" fi done #... x=0 created=0 user in ${usernames[*]} useradd -n -c ${fullnames[$x]} -g "${groups[$x]}" $user 2> /dev/null if [ $? -eq 0 ] let created=$created+1 fi #... echo "${userid[$x]}" | passwd --stdin "$user" > /dev/null #... echo "welcome! account has been created. username $user , temporary password \"$password\" without quotes." | mail -s "new account $user" -b root $user x=$x+1 echo -n "..." sleep .25 done sleep .25 echo " " echo "complete. $created accounts have been created." fi
i'm guessing problem you're trying capture command output in arrays without using command substitution. want this:
groups=( $( cut... ) ) note set of parentheses $ in front of inner set.
Comments
Post a Comment