8

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?

takeshin
  • 1,471
  • 3
  • 21
  • 28

3 Answers3

14

from automated bash script:

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

and from lftp's interactive shell:

put localFileToBeSent
pQd
  • 29,981
  • 6
  • 66
  • 109
  • 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
6

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,

juj
  • 191
  • 1
  • 2
5

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

cpbills
  • 2,720
  • 18
  • 12