Put with switch "-append"

Advertisement

magowoody
Joined:
Posts:
7

Put with switch "-append"

Hi.
I can't use the -append switch connected to the put operator inside a script.
My goal is to add the content of the text file I'm sending when it is already present in the destination server.
I'm using the SFTP protocol with public key access and private key with "passphrase".

This is the relevant part of my .BAT script:
rem Generate temporary script
(
  echo open sftp://<user>@<url-sftp> -privatekey=%_pathKey%\<file>.ppk -hostkey="<privatekey>" -passphrase="<passphrase>"
  echo lcd <localpath>
  echo cd <remotepath>
  echo put -append -preservetime "<file>" <file>"
  echo put -nopreservetime "<file_fake_last_connection>" "<file_fake_last_connection>"
  echo exit
 
) > script.tmp
 
rem Run temporary script
%_path%\winscp.com /ini=nul /log=%_path%\log\<file_log.log> /logsize=5*1M /loglevel=-1 /script=script.tmp
The file is sent correctly but on the server the file is always overwritten.

At the moment I solved it by importing the file from the server and then merging it with the one to be sent on the client side, but I would be interested in understanding how to use the -append switch with the put command as per the documentation https://winscp.net/eng/docs/scriptcommand_put and https://winscp.net/eng/docs/scriptcommand_put#append.

I hope someone can help me.
Max

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,698
Location:
Prague, Czechia

Re: Put with switch "-append"

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=C:\path\to\winscp.log command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

magowoody
Joined:
Posts:
7

Re: Put with switch "-append"

> 2024-12-27 12:53:09.254 Script: put -append -preservetime "timbacq.dat" "timbacq.dat"
. 2024-12-27 12:53:09.254 Copying 1 files/directories to remote directory "/in" - total size: 840
. 2024-12-27 12:53:09.254 File: 'timbacq.dat' [2024-12-27T09:55:01.919Z] [840]
. 2024-12-27 12:53:09.254 Copying "timbacq.dat" to remote directory started.
. 2024-12-27 12:53:09.318 Preserving timestamp [2024-12-27T09:55:01.000Z]
. 2024-12-27 12:53:09.558 Transfer done: 'timbacq.dat' => '/in/timbacq.dat' [840]
. 2024-12-27 12:53:09.558 Copying finished: Transferred: 840, Elapsed: 0:00:00, CPS: 2.763/s
This is the affected portion of the log.
As you can see I also use the -preservetime parameter which however does not affect the problem.
I tried to remove it leaving only -append but there are no differences.

Reply with quote

martin
Site Admin
martin avatar

Re: Put with switch "-append"

At the very least, please post log on the Normal logging level.
Not the Reduced level: /loglevel=-1

Reply with quote

Advertisement

magowoody
Joined:
Posts:
7

Re: Put with switch "-append"

Hi Martin,
This is the portion of the log affected with /loglevel=0
> 2024-12-30 09:25:11.704 Script: put -append -preservetime "timbacq.dat" "timbacq.dat"
. 2024-12-30 09:25:11.704 Copying 1 files/directories to remote directory "/in" - total size: 1.020
. 2024-12-30 09:25:11.704   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask: timbacq.dat
. 2024-12-30 09:25:11.704   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; EncryptNewFiles: Yes; ExcludeHiddenFiles: No; ExcludeEmptyDirectories: No; InclM: ; ResumeL: 0
. 2024-12-30 09:25:11.704   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2024-12-30 09:25:11.710 File: 'timbacq.dat' [2024-12-27T09:54:41.227Z] [1020]
. 2024-12-30 09:25:11.710 Copying "timbacq.dat" to remote directory started.
. 2024-12-30 09:25:11.710 Binary transfer mode selected.
. 2024-12-30 09:25:11.710 Opening remote file.

Reply with quote

martin
Site Admin
martin avatar

Re: Put with switch "-append"

I believe it's wrong SFTP implementation on the server. It probably ignores SSH_FXF_EXCL flag, and overwrites the existing target file. Consider contacting the server provider/author. If you want me check further, please post level 2 log.

Reply with quote

Advertisement

magowoody
Joined:
Posts:
7

Re: Put with switch "-append"

Hi Martin,
I received confirmation that this flag is not currently supported in FileZilla Pro.
It will be added in the next release.
Thanks

Reply with quote

Advertisement

You can post new topics in this forum