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.
wookakaAsked:
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.

brettmjohnsonCommented:
You could use HERE i/o redirection:
http://www.dbforums.com/t1061280.html

Or you could use curl instead of ftp:
http://curl.haxx.se/mail/archive-2004-02/0086.html


0
jlevieCommented:
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.
0
wesly_chenCommented:
Hi,

-----
# !/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
binary
mget file1 file2
quit
ii
< other script >
------

Wesly
0

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?
0
jlevieCommented:
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.
0
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?
0
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.