Upload Directory Tree To Remote FTP Server Recursively
When you host your web site remotely and and the ftp server is the only way to upload all files including subdirectroies. You need to use special file transfer program such as ncftpget or ncftpput for recursive remote ftp server uploading and downloading purpose. Ncftp is considered as an improved FTP client. Ncftp’s improvements include support for command line editing, command histories, recursive gets/puts, automatic anonymous logins, and much more.
If you are RHEL / CentOS / Fedora Linux user, type the following yum command to install ncftp client (first turn on EPEL repo):
# yum install ncftp
Syntax and examples
The syntax is as follows:
ncftpput ftp-host-name /path/to/remote/dir /path/to/local/dir ncftpput -options ftp-host-name /path/to/remote/dir /path/to/local/dir |
Try the ncftpput client command as follows:
ncftpput -R -v -u "username" ftp.nixcraft.biz /nixcraft/forum /tmp/phpbb |
Where,
- -u "username" : Ftp server username
- -v : Verbose i.e. show upload progress
- -R : Recursive mode; copy whole directory trees.
- ftp.nixcraft.biz : Remote ftp server (use FQDN or IP).
- /nixcraft/forum : Remote ftp server directory where all files and subdirectories will be uploaded.
- /tmp/phpbb : Local directory (or list of files) to upload remote ftp server directory /nixcraft/forum
You can pass the password with -p option:
ncftpput -R -v -u "username" -p "passwordHere" ftp.nixcraft.biz /nixcraft/forum /tmp/phpbb |
You can use port number 2021 instead of the default FTP service port # 21 as follows:
ncftpput -R -v -u "username" -p "passwordHere" -P 2021 ftp.nixcraft.biz /nixcraft/forum /tmp/phpbb |