Link to home
Start Free TrialLog in
Avatar of wookaka
wookaka

asked on

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.
Avatar of brettmjohnson
brettmjohnson
Flag of United States of America image

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


Avatar of jlevie
jlevie

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.
ASKER CERTIFIED SOLUTION
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wookaka

ASKER

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.
Avatar of wookaka

ASKER

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?