Command line Upload file only if no file is available

Advertisement

Bostler
Joined:
Posts:
4

Command line Upload file only if no file is available

Hello

unfortunately I am forced to upload the same file to an FTP server again and again. However, this file can only be uploaded if the file does not exist on the server.

Scenario A) WinSCP uploads the file -> programme B has retrieved and deleted the file -> WinSCP uploads the same file again.
All this via task scheduling.

Scenario B) WinSCP uploads the file -> Programme B has NOT yet retrieved the file. WinSCP therefore does not upload the file -> It is then tried again 5 minutes later using task scheduling. Until scenario A comes into effect.

How can I implement this?

Translated with DeepL.com (free version)

Reply with quote

Advertisement

Bostler
Joined:
Posts:
4

Good morning. Thanks for the answer but I think the two functions do not work.
  • -neweronly: The file I have locally is always newer. Accordingly, the file on the server would always be overwritten.
  • synchronise: Will not work either. The content of each file is different. So the same thing happens. In terms of content, either the file from the server or from the local folder is overwritten.
Could it be that this function does not exist?

Reply with quote

martin
Site Admin
martin avatar

I'm sorry, but I do not understand you.
What do you mean by "The file I have locally is always newer"?
Please give us more practical description of the problem you are facing and the process you want to automate.

Reply with quote

Bostler
Joined:
Posts:
4

Ok I'll try to explain it . But it is quite complex. I have two ERP´s.
  • ERP 1 creates this csv file. As long as the file exists on the local server, this file is always extended by a new line.

  • ERP 1 pushes the csv file to an FTP server. The file always has the same name.

  • With ERP 2 I have the problem that this system can only fetch one file per hour. Therefore the file from ERP 1 must always have the same name.
Theoretically, ERP 1 tries to upload the file every 10 minutes. However, this can only happen if ERP 2 has actually retrieved this file. However, this can only happen every hour.

Both methods described by you would always overwrite the file on the FTP server. Why -> At the moment when there is no file on the FTP server, ERP 1 pushes the new file to the FTP.
So far ok.

10 minutes later, a new csv file has been created on the local server by ERP 1. This is therefore newer than the file on the FTP server.
WinSCP would now go and replace the file on the FTP server with the file from the local server.

So I am really looking for a command function that really checks whether the file already exists on the server before the upload.
If the file is still on the FTP do nothing.
If the file is no longer on the FTP, upload the new file.

Thx for your Help

Reply with quote

Advertisement

Bostler
Joined:
Posts:
4

Hello, perfect I think that's how it works. The current command is:
synchronize remote -criteria=none -filemask=*.csv C:\datein\ /public_html/Test/
So it is possible to move the local file to an archive but ONLY if the new file has been uploaded?

So as long as the system does nothing, the file should remain in the folder and when the file is then uploaded to the FTP server, it should be moved to a subdirectory called archive.

Reply with quote

Advertisement

You can post new topics in this forum