Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to duplicate a directory on an FTP server I'm connected to from my Mac via the command-line

Let's say I have file. I want to have files2 with all of file's subdirectories and files, in the same directory as the original. What would be the simplest way to achieve this?

(I´m a complete newbie to the UNIX command line, so sorry if the question is not clear enough; please ask for any clarification needed.)

EDIT:

With mget and mput you could download all files and upload them again into a different folder but this is definitely NOT what i want/need (I started this question trying to avoid duplicating with this download upload method from the dektop client)

share|improve this question
add comment

5 Answers 5

up vote 6 down vote accepted

What you have is not a unix command line, what you have is an FTP session. FTP is designed primarily to upload and download files, it's not designed for general file management, and it doesn't let you run arbitrary commands on the server. In particular, as far as I know, there is no way to trigger a file copy on the server: all you can do is download the file then upload it under a different name.

Some servers support extensions to the FTP protocol, and it's remotely possible that one of these extensions lets you copy remote files. Try help site or remotehelp to see what extensions the server supports.

If you want a unix command line, you need remote shell access, via rsh (remote shell) or more commonly in the 21st century ssh (secure shell). If this is a web host, check if it provides ssh access. Otherwise, contact the system administrator. But don't be surprised if the answer is no: command line access would be a security breach in some multi-user setups, so there may be a legitimate reason why it's not offered.

share|improve this answer
    
I´ll check it out I think this sums up the whole issue very well!! thank you VERY much!! –  Trufa Nov 11 '10 at 22:07
    
Just to clarify, Hostgator offers jailed ssh in shared accounts. –  Trufa Nov 11 '10 at 23:01
add comment

This is wrong now, but keeping undeleted so the comment tree isn't lost

cp copies files and directories; you can give it the -r flag to make it recursively copy everything. From the folder that contains file:

$ cp -r file files2

share|improve this answer
    
It doesnt seem to be working, I failed to mention (because I though it would be the same) that I am trying to do this via an FTP connection established from a mac terminal. It gives me this error: 'cp' macro not found. Thanks –  Trufa Nov 11 '10 at 17:53
2  
@Trufa Oh! No, that's quite different; FTP and the command-line are completely separate. I edited your question to hopefully clarify –  Michael Mrozek Nov 11 '10 at 17:56
    
Im so sorry, I though it wouldnt mind because "I was using the UNIX command line via FTP", this is obviously not the case! Thanks for the edit!! –  Trufa Nov 11 '10 at 18:00
    
is this a question for stackoverflow? it may be more of a programming question than an UNIX one, I´n no sure. –  Trufa Nov 11 '10 at 18:35
2  
@Trufa Definitely not SO. Maybe SU, but I think it's fine here –  Michael Mrozek Nov 11 '10 at 20:15
add comment

LFTP supports higher-level commands above what the FTP protocol provides, for example its mirror command provides what you want.

There are other programs with similar features; sitecopy is another example.

share|improve this answer
    
Thanks"" looks nice, will take a look! One more question, when I acces through the cPanel to the file administrator? What am I doing, becuse it seems the hell faster to do some things than trough ftp. –  Trufa Nov 12 '10 at 12:56
add comment

Here's how to do it with lFTP:

# lftp ftp_host
user ftp_user ftp_pass
mirror source target (download entire directory tree)
mirror -R source target (reverse mirror; upload entire directory tree)
share|improve this answer
add comment

wget supports mirroring and ftp:

wget -m ftp://user:pass@0.0.0.0/dir

share|improve this answer
    
This doesn't solve the problem at all. The question is about making a copy on the server without going via the client. –  Gilles Dec 1 '10 at 18:55
    
Sorry, then I didn't understanded the question completely. –  Raymii Dec 2 '10 at 6:33
add comment

Your Answer

 
discard

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

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