ftp shell script

I need a shell script to connect to an FTP server, enter a UN/PW download 2 files, dissconnect from the server and then continue running other scripts.
I've created a script but it goes into the ftp command line and stops executing until I manually exit out of ftp.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could use HERE i/o redirection:

Or you could use curl instead of ftp:

The easiest solution to this would be to use the ncpftpget tool from the ncftp package. It is furnished with many Linux distro's, although it might be installed by default. See http://www.ncftp.com/ncftp/ for more information.

# !/bin/sh

/usr/bin/ftp -n  (ftp server or IP) <<ii
user login-name password
cd (path to the files)
lcd /home/dir-to-put-file  <== place you want to put locally
mget file1 file2
< other script >


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

wookakaAuthor Commented:
Wesly had exactly what I needed... any way to have the script echo whats happening back to the screen?
The drawback of using Wesly's technique is that you can't tell if the transfer actually worked. The exit status of ftp will be 0 whether you actually login successfully or transfer files. Using ncftpget you'll have an exit status of 0 only if the login and transfer actually works.
wookakaAuthor Commented:
Thanks for the information but at this point I'm not too worried about error checking since the script will always be run manually. I would be intrested to see the output of the script as it runs the commands though. Anyone know how to do this if possible?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.