Thursday, August 17, 2006

UNIX Shell Script to Transfer Files via FTP

I recently needed a UNIX shell script to transfer all my files to the web collaboration server running plone. Although you can do this with Ant's FTP command, my remote system just had UNIX. Here is the script I wrote.
# This UNIX shell script FTPs all the files in the input directory to a remote directory
# It uses a UNIX Shell "hear document" to read the commands to the FTP program from the shell file
# You have to use the -n option to the FTP command to disable the prompting for the password
# the quote in front of the ftp user and pass are also necessary to disable reading from stdin
# the prompt must be turned off for the multi-put to not prompt the user

quote user $LOGIN
quote pass $PASSWORD
prompt off
mput *.*


Bharat S said...

Thanks sir :) ur script has helped me in our application development.

Ahmed said...

Thanks m8, but what if i want to make sure the file is successfully transfered? and if not to automatically retry send it?

sathish said...

Good script thanks alot it has helped me to solve my problem.
but in the scipt exit command need to be removed instead put quit to quit from ftp

Anonymous said...

I found this site using [url=][/url] And i want to thank you for your work. You have done really very good site. Great work, great site! Thank you!

Sorry for offtopic