I have the following script:
while [ "$1" != "" ]
do
case "$1" in
-h) HOST="$2"; shift 2;;
esac
done
if test -z "$HOST"
then
[...]
else
TODAY=$(date +'%Y-%m-%d')
configs=("/etc/inittab" "/etc/default/cron" "/etc/default/login" "/etc/default/su" "/etc/group" "/etc/inet/inetd.conf" "/etc/mnttab" "/etc/netmasks" "/etc/nsswitch.conf" "/etc/protocols" "/etc/services" "/etc/syslog.conf" "/var/sadm/install/contents" "/etc/user_attr" "/etc/passwd")
ssh $HOST
for (i=0; i<${#configs[*]}; i++)
do
digest -v -a md5 ${configs[$i]} | awk '{print $2,$4}' | sed 's/) (/\n/;s/[()]//g';
done > /tmp/md5_config_$TODAY.txt
fi
If I execute the script with a hostname (scriptname.sh -h hostname) I get the error
line 97: syntax error near unexpected token `('
line 97: `for (i=0;i<${#configs[*]};i++;); '
Is there a way to solve it? I want to execute the "digest" command on the remote host with the filenames of the array "configs"
Edit: Actual state
else
TODAY=$(date +'%Y-%m-%d')
configs=("/etc/inittab" "/etc/default/cron" "/etc/default/login" "/etc/default/su" "/etc/group" "/etc/inet/inetd.conf" "/etc/mnttab" "/etc/netmasks" "/etc/nsswitch.conf" "/etc/protocols" "/etc/services" "/etc/syslog.conf" "/var/sadm/install/contents" "/etc/user_attr" "/etc/passwd")
ssh $HOST
for ((i=0; i<${#configs[*]}; i++))
do
digest -v -a md5 ${configs[$i]} | awk '{print $2,$4}' | sed 's/) (/\n/;s/[()]//g';
done > /tmp/md5_config_$TODAY.txt
fi
i++in the line 97.;at the end of the linefor(i=0.....)