what's worng with this code

Below is the simple shell script code for ftp files from Remote server -

while true
do
echo "Coping files from remote server"
sleep 1
ftp -inv $IP <<!
user $USER $PASS
cd /dcs/data01/INPUT/MSC/ERI
lcd /dcs/appl01/testing_scenario
bin
mget ERVNS*
bye
!
sleep 60
done

I am running command on Linux box and getting error -

"syntax error: unexpected end of file"

Please let me know what's wrong with this code. However when I run same command on prompt it is working.

try...

while true
do
echo "Coping files from remote server"
sleep 1
ftp -inv  <<!
open $IP
user $USER $PASS
cd /dcs/data01/INPUT/MSC/ERI
lcd /dcs/appl01/testing_scenario
bin
mget ERVNS*
bye
!
sleep 60
done

The error message is because the "!" is somehow not in column 1 on a line on its own. It can be caused by editing the script on a M$ platform.

Can you post the output from:

sed -n l scriptname

Based on you post, it should look like this:
The "$" represents the standard unix line terminator.

while true$
do$
echo "Coping files from remote server"$
sleep 1$
ftp -inv $IP <<!$
user $USER $PASS$
cd /dcs/data01/INPUT/MSC/ERI$
lcd /dcs/appl01/testing_scenario$
bin$
mget ERVNS*$
bye$
!$
sleep 60$
done$

Hi Methyl,

Thanks for reply

Below is the output of sed -n l <my_script>

while true\r$
do\r$
echo "Coping files from remote server"\r$
sleep 1\r$
ftp -inv $IP <<!\r$
user $USER $PASS\r$
cd /dcs/data01/INPUT/MSC/ERI\r$
lcd /dcs/appl01/testing_scenario\r$
bin\r$
mget ERVNS*\r$
bye\r$
!\r$
sleep 60\r$
done\r$

it looks good to me. Please check.

Thanks.

Am very sure,

that the pattern <<!
and
!

is not the same,

there is same character - a whilte space ?, that is making this incomplete file

Can you please check that?