我正在尝试创建一个脚本,该脚本接受多个用户输入。当我调用脚本并提供多个输入时,如果提供多个输入,则脚本将不会执行。我在这里做错什么了。
#! /bin/bash
server_list=()
echo "Enter server name: "
readarray -t servername
declare -p servername
sudo showsudolocal $servername | tr -d '$' | sed -e '/^$/d' | tee output.txt
sed -i 1,8d output.txt
mapfile -t myArray < output.txt
count=${#myArray[@]}
for (( i=1; i<$count; ))
#for i in `seq 1 $count`
do
str="${myArray[$i]}"
echo "str is $str"
IFS=',' read -r -a array <<< "$str"
i=$((i+2))
username="${array[0]}"
groupname="${array[1]}"
echo "Username is $username"
if [[ -z "${array[0]}" ]] || [[ "${array[0]}" == *'*'* ]]
then
echo "group"
sudo docentcmd $servername centclicmd adquery group $groupname
cat /etc/group | grep $groupname
else
echo "User"
sudo docentcmd $servername centclicmd adquery user $username
cat /etc/passwd | grep $username
fi
done