Topic "Trying to append txt files fails"

Author Message
JustAsking
[View user's profile]

Joined: 2017-01-09
Posts: 12
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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
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.
JustAsking
[View user's profile]

Joined: 2017-01-09
Posts: 12
Here you go...

Thanks!
SCPLog.log (18.37 KB) Private file

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
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?
JustAsking
[View user's profile]

Joined: 2017-01-09
Posts: 12
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

Description: (none)

TransferTest.ps (2.95 KB) Private file

Description: (none)

JustAsking
[View user's profile]

Joined: 2017-01-09
Posts: 12
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.
TransferTest.ps (2.95 KB) [Download]

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
Can you answer my question?
martin wrote:
In GUI, when you re-upload a file, do you get overwrite confirmation prompt?
JustAsking
[View user's profile]

Joined: 2017-01-09
Posts: 12
I get the "standard" upload dialog, then the transfer dialog flashes quickly (as the file is small) and done. No overwrite warning.[/img]
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.
JustAsking
[View user's profile]

Joined: 2017-01-09
Posts: 12
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...
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
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.
JustAsking
[View user's profile]

Joined: 2017-01-09
Posts: 12
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...
JustAsking
[View user's profile]

Joined: 2017-01-09
Posts: 12
Also as an FYI, I am using IPSwitch WS_FTP version 7.7.0 for the SFTP server software.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
Can you attach a log file both for (working) GUI overwrite and (non-working) script append?
Advertisements

You can post new topics in this forum






Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License