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.

How to copy file on remote server using lftp?

Moving files is as easy as using mv command, but is there any command equivalent to cp?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

from the man page:

ftpcopy
Obsolete. Use one of the following instead:
    get ftp://... -o ftp://...
    get -O ftp://... file1 file2...
    put ftp://...
    mput ftp://.../*
    mget -O ftp://... ftp://.../*
or  other  combinations  to  get FXP transfer (directly between two ftp
servers).  lftp would fallback to plain copy (via client) if FXP trans-
fer cannot be initiated or ftp:use-fxp is false.

so you can copy a file, by doing:

get filename -o ftp://user@ftpsite/directory/copyoffile

perhaps that will work better than a put/get if only because you'll be doing something like FXP, and the server will be using its own local bandwidth

share|improve this answer

from automated bash script:

lftp -u login,password some.host.com -e "put file ; exit "

and from lftp's interactive shell:

put localFileToBeSent
share|improve this answer
    
Thanks for the answer, but I was asking asking how to copy file on remote server, not to the remote server. The file is already on remote server and I want to have a copy of it with diffrent name and directory. Do I have to use local server, get and put commands for this? –  takeshin May 15 '10 at 15:43
    
it looks that way, just looking at the help output in lftp, there's nothing that even hints at a copy command. get/put looks like how you'll have to do it. –  cpbills May 15 '10 at 17:32
    
@cpbills afaik it's not a standard command so your will need some luck and support for whateever it is on the other end of your connection. –  pQd May 15 '10 at 17:40
    
how do you mean? get and put are fairly common commands. did you mean to put the comment on my answer? and yeah, a server needs to support fxp in some capacity, but it's an actual solution. –  cpbills May 15 '10 at 19:34

Check the mirror builtin to transfer one or several files :

lftp builtin mirror can download or update a whole directory tree. There is also reverse mirror (mirror -R) which uploads or updates a directory tree on server. Mirror can also synchronize directories between two remote servers, using FXP if available.

So,

  • lftp> mirror -R ftp://from.example.com/directory1 -i file1 ftp ://to.example.net/directory2
  • lftp> mirror -R ftp://from.example.com/directory1 ftp://to.example.net/directory2
share|improve this answer

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.