Upload A Whole Local Directory To A Remote Directory Using FTP And Command Line In Fedora 9

Since I was looking to offload some of the resources that the PGN servers were taking to another host other than my dedicated server, I tried looking for free web hosts that allows you to upload files via FTP. And when I found one, I thought to myself…no way am I going to upload this using my puny upload bandwidth. I should use my dedicated server’s upload bandwidth – which is 100mbit. And so, with only a command line interface to play with, I seek out how to upload whole local directories to a remote directory.

I stumbled upon ncftpput. When you do man ncftpput it says in the description that The purpose of ncftpput is to do file transfers from the command-line without entering an interactive shell. This lets you write shell scripts or other unattended processes that can do FTP. It is also useful for advanced users who want to send files from the shell command line without entering an interactive FTP program such as ncftp.

You’re probably itching already how to do it and you honestly don’t care what the description says so I’ll just end it there and we’ll move to how I exactly did it.

Ok, first off let’s say you have the following info…

Local Directory: /tmp/upload/myfiles

Remote Host FTP: ftp.remotehost.com

Remote Host FTP Username: username

Remote Host FTP Password: password

Remote Directory: /upload

ncftpput –R –v –u username ftp.remotehost.com /upload /tmp/upload/myfiles

So what just happened? After you execute that command, it’ll try and connect to your remote FTP and ask for your password and then the rest is just well…waiting for it to get done.

Well the ncftpput modes are…

-R recursive mode or copy the whole directory tree.

-v verbose mode, meaning you’ll see what’s happening in your console screen.

-u username use ‘username’ in the command line.

Hope that’s helpful guys. I’m learning as well, haha.

Tags: , , ,

Leave a Reply