Please help with UNIX while loop...

Hi all. I am trying to execute a while loop that reads a log file containing a file listing, and it compares file sizes, etc.

But I am getting an error that makes it seem like it is not reading the log file line by line. When I do a 'more' on the log file, it doesn't appear to be wrapped...

Here is the code, followed by the error output:

set good_transfer=true
while read remote_size remote_name; do
local_size=`ls -l $remote_name | tr -s ' ' ' ' | cut -f5 -d ' '`
if [$local_size <> $remote_size];
then
echo "*FATAL* $remote_name did not transfer properly">>ftp_error.log
set good_transfer=false
fi
done < `cat ftp_ls.log | tr -s ' ' ' ' | cut -f5,9 -d ' '`
"ftp1.sh" 80 lines, 2022 characters
/u/home>ftp1.sh

A file or path name is too long.
ftp1.sh[62]: ^J^J^Jfor^J^J14662 FFBA992072C1C176C1C4._IE^J1759 FFBA9E1FD7D24DBEC1C4._IE^J1207 FFBA9F3609DF7EC1C1C4._IE^J573 FFBAA1D9C583954BC1C4._IE^J2062 FFBAA56A74779104C1C4._IE^J2098 FFBAA96F6CF5AE87C1C4._IE^J6442 FFBAAA63B5F38089C1C4._IE^J1043 FFBAC24DF99141C6C1C4._IE^J2710 FFBACC7A0A095FA2C1C4._IE^J259 FFBACDE9857A2258C1C4._IE^J465 FFBAD2B13209A1B0C1C4._IE^J1966 FFBB029D0DCC4D60C1C4._IE^J1870 FFBB3EF0BCBC75E1C1C4._IE^J1272 FFBB79F1E9C4D257C1C4._IE^J1551 FFBB8537DCFDCE1BC1C4._IE^J265 FFBB853B27B34D7AC1C4._IE^J14603 FFBB859123E69D94C1C4._IE^J685 FFBBB7632A8F38C5C1C4._IE^J696 FFBBB7632B12532AC1C4._IE^J685 FFBBB7632BC81E0FC1C4._IE^J541 FFBBB78CDD015934C1C4._IE^J638 FFBBB78CDD80A3B2C1C4._IE^J427 FFBC473C92CDEE55C1C4._IE^J427 FFBC473DA6DEE64AC1C4._IE^J5509 FFBC4857EDDCA1E2C1C4._IE^J5505 FFBC4873B0B2C0E3C1C4._IE^J5505 FFBC4BCA167B7EB1C1C4._IE^J5505 FFBC4BD0ABD0B1C2C1C4._IE^J5505 FFBC4BF457DCEE7FC1C4._IE^J1249 : 0403-016 Cannot find or open the file.

help!

Looks backwards to me. As far as I know, you can not redirect from a command like this.

You can either do this:

cat ftp_ls.log | tr -s ' ' ' ' | cut -f5,9 -d ' ' | while read remote_size remote_name
do
     ...
done

or simply this:

while read remote_size remote_name
do
    ...
done < ftp_ls.log

The file must be spefied by itself in the latter example.

Thomas