ksh: 0403-057 Syntax error: `done' is not expected.

Hi

I am getting error 'ksh: 0403-057 Syntax error: `done' is not expected.' when running below script any one can provide inputs on this.

------------------------

if [ -f $1 ]
then
echo "Report Name |Modification Date|Report File Size|Owner" >SOX_`date +'%Y%m%d'`
 
while read line
do
file_name=`echo $line|cut -f1 -d':'`
file_path=`echo $line|cut -f2 -d':'`
file=`echo $file_path'/'$file_name`
 
changed=`find $file_path -iname $file_name -mtime -1 |wc -l `
if [ $changed = 1 ]
then
ls -lrt $file|awk '{print $9,"|",$6,$7,$8,"|",$5,"|",$3;}' >>SOX_`date +'%Y%m%d'`
fi
done<$1
echo "RESULT File is Generated"
########Need to add coe for mailing####
else
echo "Input file not found"
fi

-----------------------------------------------------

working perfectly on my system, look like you may have ^M chars in your script, please open in vi to verify

if [ -f $1 ]
then
    echo "Report Name |Modification Date|Report File Size|Owner" > SOX_`date +'%Y%m%d'`
    while read line
        do
            file_name=`echo $line|cut -f1 -d':'`
            file_path=`echo $line|cut -f2 -d':'`
            file=`echo $file_path'/'$file_name`
            changed=`find $file_path -iname $file_name -mtime -1 |wc -l`

            if [ $changed = 1 ]
            then
                ls -lrt $file|awk '{print $9,"|",$6,$7,$8,"|",$5,"|",$3;}' >> SOX_`date +'%Y%m%d'`
            fi
       done < $1
    echo "RESULT File is Generated"
    ########Need to add coe for mailing####
else
    echo "Input file not found"
fi
1 Like

Thanks Shailesh

when see in vi ediitor it has ^M chars in my script.
But when i see the file in text pad or note pad i dont see ane special character.
Pls suggets how to remove those characters.

---------- Post updated at 06:21 PM ---------- Previous update was at 05:48 PM ----------

Hi Shailesh

I am able to remove ^M character.

However when i ran my script it gave me below error.

'is not valid. The status on /usr/tmp
is not valid. The status on /usr/tmp
is not valid. The status on /usr/tmp
is not valid. The status on /usr/tmp
is not valid. The status on /usr/tmp
'
Basically my script reads input file which has file details and location.
if its modified in last 1 day it writes into a different file.
i think below command in my script is not working

`find $file_path -name $file_name -mtime -1 |wc -l `

also i noticed that in my unix box fnd -iname options is not working it says invalid -iname option.

Thanks,

---------- Post updated at 06:43 PM ---------- Previous update was at 06:21 PM ----------

Hi All

ignore my previous post.

I am able resolve .

Thanks,