Nelson Teixeira
Nelson Teixeira

Reputation: 6562

With LFTP How do I send a specific file to server overwriting if it exists?

I'm building an production site update script using expect and lftp.

I'm trying for sometime to do this simple thing: send a file overwriting if it exists. But I just can't find a command that allow me to overwrite destination on put. put -c just continues if it's the same file. But if it's different it does nothing.

Do I really have to check if the file exists and delete it in order to put the file in the server ? isn't there a direct command ?

If that's the only option, then there's another thing I couldn't find: a command to see if the file exists. My only option is to treat ls's output ?

I also accept recommendations if there's another ftp client that allows me to do these things in an easier manner.

Upvotes: 2

Views: 4930

Answers (1)

gravity
gravity

Reputation: 2056

LFTP offers a parameter for put which is a lowercase e.

This allows you to remove the file before uploading it, as opposed to an overwrite option (which LFTP doesn't appear to inherently support). Things like prompt could be available, but if we're strictly discussing LFTP, I would recommend using that option, ala:

put -e file.txt

From the LFTP man pages.

Upvotes: 2

Related Questions