Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am logged in on a server (using Putty). from there I'm connecting using FTP to another server. I want to copy several folders from the first server to the second server using mput.

Like: ftp> mput folder1 folder2 folder3

But I get "folder1: not a plain file."...and so on. Each of these folders have subfolders, files (some binary, some not).

How can I accomplish what I want without zipping the stuff and then transfer?

Thanks.

share|improve this question

5 Answers 5

Command line FTP is pretty primitive.

You can't recursively send files/folders towards a remote site.

If you want to recreate a directory structure on the remote side the same as the local, you need to manually mkdir each path and use *mput ** to send everything in that directory to the remote side.

Two options to make this easier:

  1. Stop using the primitive FTP command (ncftp is a good alternative)

  2. Use tar to tar up the folders, send the file and extract on the far side.

share|improve this answer

I made a bash script:

#!/bin/bash
ftp_site=ftp.yoursite.net
username=my_user_name
passwd=my_password
remote=/path/to/remote/folder
folder=$1
cd /path/to/local/folder/$folder
pwd
ftp -in <<EOF
open $ftp_site
user $username $passwd
mkdir $remote/$folder
cd $remote/$folder
mput *
close
bye

and called it with

find . -type d -exec ./recursive-ftp.sh {} \;

seems to work.

share|improve this answer

This is not possible with the normal ftp program as mput does not use recursion. You could use ncftp and then call 'mput -r folder'.

Best wishes, Fabian

share|improve this answer
    
That's exactly what I did recently on an RHEL 5 box. In the EPEL package, the executable is named ncftpput. –  Suppressingfire Dec 4 '09 at 20:04
    
Can't change anything in the server's configuration. I'm just an user... –  Mircea Dec 4 '09 at 20:10
    
It depends on your client. Not on the server. –  halfdan Dec 4 '09 at 21:53

Secure Copy scp has a -r recursive flag that you might find useful.

share|improve this answer

open powershell cd to the directory you want to upload run the following commands:

1. gci -r | % {if ($_.PSIsContainer) {$t = $((($_.fullname -split "\\")[$(((pwd) -split "\\").length)..200]) -join "/"); "mkdir ""$t""`r`nmput ""$t/*"" ""$t"""}} | sc .\mput_all
2. notepad .\mput_all

Paste the results into your ftp window. Enjoy. Also don't forget to add mput * to transfer all the files from the base directory.

share|improve this answer
4  
Since when does PowerShell run on a Unix system? –  Michael Hampton Apr 15 at 0:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.