2

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Nelson Teixeira
  • 6,297
  • 5
  • 36
  • 73
  • a regular FTP PUT should overwrite the remote file with local by default, innit? –  Nov 26 '18 at 15:12
  • Doesn't overwrite in the server I'm using. Tested it.Just to see if had done something wrong last week, I retested it right now. Doesn't overwrite. – Nelson Teixeira Nov 26 '18 at 15:14
  • `put -e` should overwrite and remove the file prior to upload. Make sure you use a **lowercase** `e` as an uppercase `E` would actually remove from your local system. See the [LFTP man page](https://lftp.yar.ru/lftp-man.html) – gravity Nov 26 '18 at 15:16

1 Answers1

2

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.

gravity
  • 2,175
  • 2
  • 26
  • 34
  • 1
    This page is inaccessible from my company's internal network and LFTP's console help doesn't list this option. Thanks. That was what I needed. The reward is yours :) I can only award the reward after 24 hours. After that period I'll give it to you. – Nelson Teixeira Nov 26 '18 at 15:31