Trouble connecting to FTP proxy server

Hi Guys,
I have trouble connecting to ftp server. My task is to connect to the proxy server and get the latest file to the local machine. It works fine when i do the same steps manually. I've been trying to do it in multiple ways but im just not able to connect. When i check the log, this is what it says:
Connected to ftpproxy.xx.xxxx.com.
220 <ip address> CSM Proxy Server FTP Proxy ready for login
ftp>
It is not going beyond this.

Below is my script: (we are using Linux)
#!/bin/sh
$server=ftpproxy
$user=user k123456@xxx.abcdef.com
$password=password
$dir=/abc/xyz/work
$filename=1234.def.ghi.$$

cd $dir (on local machine)
ftp -u $server <<EOF (connecting to the proxy server)
##i tried using -n as well...but it is not working
#the script is not going beyond this point
user $user $password
##i tried giving password in the next line as well, like this:
#user $user
#$password
ls
binary
get $filename
bye
EOF

I too have the .netrc file in the HOME directory but with a different name.

FYI..this is what i do manually:
ftp -u ftpproxy
ftp> user k123456@xxx.abcdef.com
ftp> <<password>>
ftp> ls
ftp> binary
ftp> get file
ftp> bye

Please help me connecting to the FTP server...because this being the first step in the script..i am not able to execute the other steps as well.

Thanks in advance!!

use .netrc or write an Expect wrapper script

how do i use .netrc or write an expect wrapper script...
During my investigation i found that by using .netrc we can enable autologin. But i was not able to find how do we include that in the script.
Could you please provide me some more information regarding this?

Thanks!!

search the forums or google. plenty of examples out there.

Though this sounds silly...Can i write expect script in Linux environment?

If so...will this work?

#!/bin/sh
server=ftpproxy
user_id=user k123456@xxx.abcdef.com
password=password
dir=/abc/xyz/work
filename=1234.def.ghi.$$

cd $dir

spawn ftp $server
expect "username:"
# Send the username,
send "$user_id\r"
expect "password:"
# Send the password,
send "$password\r"
expect "ftp>"
# Switch to binary mode,
send "bin\r"
expect "ftp>"
# Turn off prompting.
send "prompt\r"
expect "ftp>"
# Get all the files
send "mget $filename\r"
expect "ftp>"
send "bye\r"
expect eof

Please let me know if i have to make any changes to the script.
Thanks in advance!!