Trying to append txt files fails

Advertisement

JustAsking
Joined:
Posts:
14

Trying to append txt files fails

When using the sample powershell script (here is the important part):

# Upload files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.OverwriteMode = [WinSCP.OverwriteMode]::Append

$transferResult = $session.PutFiles( 'Test01.txt', "remotefile", $False, $transferOptions)

Should append the source file to the end of the target file, yes? It overwrites it every time. I tried setting TransferMode to Ascii and that made no difference.

Am I doing something stupid? The only "real" change I made to the sample script is adding the OverwriteMode setting.

Once I get this to work, I will actually be incorporating it into a much larger program.

I am using version 5.9.3 (Build 7136). Thanks.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: Trying to append txt files fails

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

To generate the session log file, set Session.SessionLogPath. 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

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

The server behaves like if the file does not exist.
In GUI, when you re-upload a file, do you get overwrite confirmation prompt?

Reply with quote

JustAsking
Joined:
Posts:
14

Here is the latest log file that was generated by the attached powershell script.

The script creates some simple files and uploads them two different times, two different ways to the SFTP server. The first time as a single wildcard upload to a single target file and the second time as individual files to a single target file. In both cases, the target file only contains the last uploaded file.

I have tried this with a TransferMode of Ascii and Binary. Same results either way.

You will need to change the "ps" to "ps1" to execute...

Thanks for your assistance!
  • SCPLog.Log (19.31 KB, Private file)
  • TransferTest.ps (2.95 KB, Private file)

Reply with quote

JustAsking
Joined:
Posts:
14

In case I am doing something "stupid" (very likely), here is the powershell script for anyone to look at. If you choose to download it, copy it to a directory, copy the WinSCP.dll to the same directory, change the extension from *.ps to *.ps1, and edit to to add in YOUR SFTP site and access credentials. Thanks all.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Can you answer my question?

martin wrote:

In GUI, when you re-upload a file, do you get overwrite confirmation prompt?

Reply with quote

JustAsking
Joined:
Posts:
14

I get the "standard" upload dialog, then the transfer dialog flashes quickly (as the file is small) and done. No overwrite warning.[/img]

Reply with quote

Guest

Upgraded to latest version:

2017-06-26 09:45:04.557 WinSCP Version 5.9.6 (Build 7601) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional)

Same issue with script and GUI transfer.

Thanks.

Reply with quote

JustAsking
Joined:
Posts:
14

Anonymous wrote:

Upgraded to latest version:

2017-06-26 09:45:04.557 WinSCP Version 5.9.6 (Build 7601) (OS 6.1.7601 Service Pack 1 - Windows 7 Professional)

Same issue with script and GUI transfer.

Thanks.

Sorry, this be me...

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

JustAsking wrote:

I get the "standard" upload dialog, then the transfer dialog flashes quickly (as the file is small) and done. No overwrite warning.[/img]
Assuming you have overwrite confirmations enabled (they show with other servers), then this is a clear indication of a bug in the SFTP server. WinSCP uses a flag, when creating a remote file, that instruct the SFTP server to fail to overwrite the file, when the file already exists. WinSCP uses the failure to trigger an overwrite confirmation and/or append mode. As the server "fails to fail", WinSCP carries on with a regular upload.

Reply with quote

JustAsking
Joined:
Posts:
14

OK, this is just weird...

I downloaded and installed the latest version (per previous post) and tried uploads with no change (still over writing with no warning). Was working on coding a work-around and due to something not related to this I did a system reboot.

NOW I am getting the dialog (via the GUI) about over writing an existing file and it is asking me if I want to proceed or not. In addition though, when I say yes I get an error dialog saying:

Upload of file '(name)' was successful, but error occurred while setting the permissions and/or timestamp.

The specific error details are:

The server does not support the operation.
Error code: 8
Error message from server: SSHServerAPI.SFTP.fxp_attrs


Tested the script uploads again as well and it still does an overwrite versus an append...

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Can you attach a log file both for (working) GUI overwrite and (non-working) script append?

Reply with quote

Advertisement

You can post new topics in this forum