ssh script problem problem

Hi

Please help me with the following problem with my script.

The following block of code is not repeating in the while loop and exiting after searching for first message.

input_file

host001-01
host001-02
2008-07-23 13:02:04,651 [DEBUG] [ageListenerThreadPool : 0] ConnectionFactory - Setting session state for connection.
2008-07-23 12:59:47,203 [DEBUG] [ageListenerThreadPool : 2] ConnectionFactory - Setting session state for connection.
host001-03
2008-07-24 11:51:56,883 [DEBUG] [AQUEDUCT-WebContainer : 1] ConnectionFactory - Setting session state for connection.
2008-07-24 11:47:18,448 [DEBUG] [ageListenerThreadPool : 2] ConnectionFactory - Setting session state for connection.

Shell script code

while read line; do

temp_output=`echo $line | grep host001`

if [ "$temp_output" != "" ]; then

SERVER="$line"

else

thread_name=`echo $line | awk '{print $4,$5,$6}' | perl -wn -e 'print "$1\n" if m{[\[](.*?)[\]]};'`

date_string=`echo $line | awk '{print $1,$2}'`

ssh $SERVER cat "\`find / -mtime -1 -name 'app.log*' | sort -r\`" | fgrep -H -B25 '$date_string' | egrep -e 'The Message is' | egrep -e '$thread_name';

fi

done < $input_file

Expected Output:

It should search for the strings on each host and display the message ( Please note that i have modified code to paste in the forum) and instead it's displaying output for first message(2008-07-23 13:02:04,651 [DEBUG]) and exiting the script and no error messages.

Use ssh -n otherwise it gobbles up the stdin provided to your while read line ; do ... done loop.

You are awesome man. It worked like a charm ...

Thank you very much