Deleting File from FTP and Transferring File to FTP

Hi,

I am getting error when i am deleting file from FTP and also transferring file from local to FTP server.

I am getting 221 error. I am getting this error some time only.

Some time the existing file from FTP is deleted and file from local directory is transferred to FTP server.

Some time the existing file from FTP is deleted and file from local directory is not transferred to FTP server.

My code is like below

ftp -n -v <FTP Server> <<INPUT_END> LOGFILE.txt
quote user <user name>
quote pwd <password>
cd <FTP Path>
mdelete INS_7131*.IN
mput <FILE Name>
INPUT_END

Is there any syntax error in above code.

This is urgent. Pls tell me why sometime the file is transferred to FTP and sometime not transferred to FTP server.

Pls give me the solution as early as possible.

221 Service closing control connection.
Logged out if appropriate.

ftp returns series codes - numbers like 500 or 221. These codes tell you what happened to a particular request. 221 can mean things like 'the connection was lost' for example.
You have to ask yourself - why would the remote server close the connection?
Or why would it look like that from my end? If you need an absolutely detailed account, you would have to be able to monitor what was going on at the remote host just when it returned 221.

The simple answer is to retry the operation. If it fails three times, send an email to the sysadmin or whoever is appropriate. This means you have to check codes in the script. For a complete list of these codes go to RFC 959
http://www.faqs.org/rfcs/rfc959.html

Assuming normal FTP, the script as posted contains errors.
1) No space character after the first INPUT_END
2) FTP login line incorrect.

Maybe try it with a ftp "dir" command first to ensure that you can connect.

ftp -n -v <FTP Server> <<INPUT_END >LOGFILE.txt
user <user name> <password>
cd <FTP Path>
dir
INPUT_END