The ftp command is designed for interactive use. For scripts, use the ncftp group of commands, or, if possible, use scp.