There are two ways I found to use the ftp commands in shell script. One is using curl and other is normal ftp session.
curl ftp://username:email@example.com/folderifany/filename.ext > localfilename.ext
The above command will copy the file from ftp location to local directory. It will work by simply adding the above command to the shell script. This outputs the activity to the console though so you will have to take care of that.
Using normal FTP session:
ftp -u ftp.yourdomain.com << END_SCRIPT user username password cd folderifany get filename.ext bye END_SCRIPT
I googled around and found the above command using -n which was not working for me so i used -u and it worked! And this does not write any activity on the console.
You can use any normal ftp command inside the ftp session like ls, put etc and they will work as they do on command prompt.