Linux/Mac Recursive FTP Using Built-in FTP Programme

I had to fetch a few thousand files across a few directories on a remote server recently and I was going to use NCFTP, however I’d remembered that the stock ftp program on linux can in fact do a recursive fetch. You need to remember to turn the interactive prompts off as well, because if you don’t then you will have to press the ‘Y’ key to download each file.

~

I had to fetch a few thousand files across a few directories on a remote server recently and I was going to use NCFTP, however I’d remembered that the stock ftp program on linux can in fact do a recursive fetch. You need to remember to turn the interactive prompts off as well, because if you don’t then you will have to press the ‘Y’ key to download each file.

# Open connection  
ftp user@host.com

# Change directory
cd to/the/path

# Turn the interactive prompt off
prompt off

# Use the command 'mget' to fetch the files, the glob (*) will execute
# on the remove server
mget *

# Exit cleanly
exit

 


~

Comments