I have for example database backups on my Linux server, and I would like to write a script to upload it to remote FTP. I tried the put command, but it can only transfer one file at a time. Then I tried the mput command, but it just shows me question marks for files I want to transfer (maybe I'm using it wrongly?..)

I tried this:

ftp -n <<EOF
open ftp.server.com
user name password
cd backup
mput /backup/*

But it won't work. It outputs names of files I want to transfer with question marks at the end of names. Am I missing something or maybe there is better simpler way?


Take a look at ncftp, it comes with an utility (ncftpput) that can be scripted for this purpose:

$ ncftpput -R ftp.server.com /remote/path /backup

The -R flag means recursive mode. You can have your authentication details in a separated file. See the manpage (ncftpput(1)) for details.

  • I was about to suggest ncftp too. Use it all the time (and its bookmarks feature is great :)). – user Oct 11 '13 at 7:31
  • For some reason it wronlgy installed or didn't install at all. It gives me error -bash: ncftp: command not found. In install log it said it succesffuly installed, but I also saw warnings like these -" insserv: warning: script 'NcFTPd' missing LSB tags and overrides insserv: There is a loop between service redmine and NcFTPd if stopped insserv: loop involving service NcFTPd at depth 2 insserv: loop involving service redmine at depth 1 insserv: Stopping NcFTPd depends on redmine and therefore on system facility `$all' which can not be true!" – Andrius Oct 11 '13 at 7:38
  • 2
    @Andrius Are you sure that you installed the client and not the server? The error message definitely suggests you installed the server. – user Oct 11 '13 at 7:42
  • Right.. How I didn't see that :) – Andrius Oct 11 '13 at 7:48

Another alternative might be to use CurlFtpFS, a FUSE file system driver that exposes a FTP host as a mounted directory (allowing you to access those files with any regular tools, including cp). I don't know how well it works, but from a quick googling around it looks very promising. CurlFtpFS goes back further than does FUSE actually, so should be stable.

To use it, install the appropriate package for your distribution (for example, Arch and Debian use the package name curlftpfs), load the fuse module, and sudo curlftpfs ftp.example.com /mnt/ftp/ -o user=username:password,allow_other, substituting appropriate values for server name, mount point, user name and password.

There are further details at the linked page but that should get you started.


You could use lftp

lftp ftp://user:password@domain.ltd -e "mirror -e -R /local/folder /remote/folder ; quit"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.