Unix FTP Script connecting through proxy Not working

Hi All,
can some one please help me to solve this issue, its urgent:confused:
We need to FTP a file form our Unix server to an external client FTP location.
I am trying to connect to the proxy server first and then use the below USER comment to connect to the external FTP server, and its working correctly when I am doing it manually
user <userid>@<ftpservername> <password>
But when I try to user the same comment in a shell script its not working.
Can some one please tell me whether this type of connection is possible from the script.

Script code
#!/bin/sh
ftp -n <proxy server addres> <<END_SCRIPT
quote USER '<userid>'
quote PASS '<password>'
user <remote user id>@<remote sever name> <password>

Please see the error below that I am getting when I run the script

ERROR LOG
Connected to ftp-gw.glb2.hedani.net.
220 Welcome to the <company name>....
331 Enter authentication password for user id
230 User authenticated to proxy
331-(----GATEWAY CONNECTED TO <enternal server name>----)
331-(220-Microsoft FTP Service)
331-(220 Lighthouse FTP - Accesses and activities are logged. Illegitimate reque
sts for service will result in legal action.)
331 Password required for <remote user id>.
530 User <remote user id> cannot log in.
Login failed.
530 Please login with USER and PASS.
221 Goodbye!

thanks for your help
Joseph

Does the last password need to be on a new line perhaps?, e.g.:

#!/bin/sh
ftp -n <proxy server addres> <<END_SCRIPT
quote USER '<userid>'
quote PASS '<password>'
user <remote user id>@<remote sever name> 
<password>
END_SCRIPT

The end of the heretext was also missing, if that still does not work i would try using expect(1) instead of heretext, something like:

#!/usr/bin/expect
spawn ftp -n <proxy server address>
epect "Name"
send "USER <userid>\r"
expect "password for user id"
send "<password>\r"
expect "to proxy"
send "user <remote user id>@<remote sever name> \r"
expect "Password required for"
send "<password>\r"

(other commands or interact)

expect eof

What to expect(1) will need amending to what appears on the screen before each response but you'll get the gist of what I am trying to do above.

#!/bin/sh
ftp -n <proxy server addres> <<END_SCRIPT
quote USER '<userid>'
quote PASS '<password>'
user <remote user id>@<remote sever name> <password>

As TonyFullerMalv has spotted the above script contains spurious "quote" statements. He has also spotted that the END_SCRIPT termination line for the unix here document is missing.

Personally I would use a ".netrc" file to provide the username and password for the connection to the proxy server and then present the "user" line within a unix here document.

Double post, continued here. Thread closed.