Situation:
I am parsing a conf file with the snippet below:
241 exec 3<&0
242 exec 0<"$CONFIG_FILE"
243
244 #process the config file.
245
246 while read line
247 do
248 if [ "${line:0:1}" != '#' ]; then # first letter isn't #
249 {
250 echo "iter"
251 process_conf $line;
252 }
253 fi
254 done
255
256 exec 0<&3
process_conf looks like so:
209 process_conf ()
210 {
211 line_in="$@"
212 echo "$line_in" 1>&2
213 copy_log $line_in
214 move_log $line_in
215 delete_old_log $line_in
216 }
The problem is in delete_old_log. Line 181 breaks the iteration over the lines in the conf... it only runs the first call to process_conf.
If I comment out the ${SSH_FULL}, the iterations in the first section I pasted continue fine. I initially thought I may be clobbering the file descriptor I was readin the config from with the output redirection, but doing the same thing with echo (see the commented out line on 182) does not produce the same problem.
164 delete_old_log ()
165 {
166 name_tag="$1"
167 log_src="$5"
168
169 if [ -n "${skip_this_file}" ]; then
170 {
171 copy_running=
172 skip_this_file=
173 current_temp_log=
174 return
175 }
176 fi
177
178 # DELETE the old file here if they are the same.
179
180 SSH_FULL="${SSHCMD} -p ${ssh_port} ${log_user}@${log_server}"
181 ${SSH_FULL} "${MD5} ${log_src}" > "${TMPDIR}/tmp.$$"
182 #echo "hi" > "${TMPDIR}/tmp.$$"
183
184 remote_md5=`cat ${TMPDIR}/tmp.$$ | ${AWK} '{print $1}'`
185 ${RM} -f "${TMPDIR}/tmp.$$"
186 local_md5=`$MD5 "${final_log}" | awk '{print $1}'`
187
188 if [ "${remote_md5}" = "${local_md5}" ];
189 then
190 {
191 echo "${name_tag}: `date` - Deleted old log ${log_src}." 1>&2
192 # ${SSH_FULL} "rm -f ${log_src}" > /dev/null 2>&1
193 }
194 else
195 {
196 echo "${name_tag}: `date` - MD5SUM mismatch between ${log_src} and ${final_log}. Skipping delete!"
197 }
198 fi
199
200 echo "delete complete"
201 # cleanup prior to exit;
202 final_log=
203 copy_running=
204 skip_this_file=
205 current_temp_log=
206 echo "next file..."
207 }