Run FTP session from bash script
use scriptable ftp client like lftp.
you use it like this:
lftp -u login,pass host.com -e "get file.txt;exit "
or even simpler - use wget:
wget -O file ftp://login:[email protected]/file.txt
I've encountered issues redirecting STDIN with UNIX ftp clients before. While I'll often try to work through them, I've found expect to be better suited in many situations.
You might also take a look at nagios-plugins check_ftp, as you could potentially pull that out and use it for your purposes. Often, there's little need to reinvent the wheel.
To specifically answer your question, FTP's netrc file will provide the authentication details on your behalf.