You have to pass ftp commands as standard input to the ftp statement. Use a "here document" like in the following example:
Code:
ftp -ni host << EOF > /dev/null
user username password
ls
bye
EOF
Note that the closing EOF must be at the beginning of the line (no leading spaces or tabs) otherwise it is not interpreted from the shell and the standard input is not terminated. Also the user command let you avoid to interactively type username and password. A downside is that you have to write the password in clear text in a script and other people may read (and use) it.