@acs68a: Ok, but that's a workaround, not a solution.
- martin
transferOptions.AddRawSettings("IgnorePermErrors", "1");
TransferOptions.PreserveTime = false
is ignored for synchronization, unless you use SynchronizationCriteria.None
or SynchronizationCriteria.Size
.
SynchronizeDirectories
fails with the errors posted above when attempting to sync multiple files to an Ipswitch WS_FTP 7.5 SFTP server, but when performing the same sync of multiple files to an SSH Systems Tectia SFTP server, no errors are seen in the log file. Yes, I am passing the TransferOptions
.
;** Set WinSCP SFTP component options
objSessionOptions = ObjectClrNew( 'WinSCP.SessionOptions' )
objProtocol = ObjectClrNew( 'WinSCP.Protocol' )
Sftp = ObjectClrType( 'WinSCP.Protocol', objProtocol.Sftp )
objSessionOptions.Protocol = Sftp
objSessionOptions.HostName = serverName
objSessionOptions.UserName = userID
objSessionOptions.Password = userPassword
;Get the host key fingerprint by using winscp GUI version to connect to the FTP server with the ID you will be using.
objSessionOptions.SshHostKeyFingerprint = "ssh-rsa 1024 f1:****removed******
;objSessionOptions.GiveUpSecurityAndAcceptAnySshHostKey ; if you don't want to mess with fingerprint, use this
;Create an instance of the WinSCP.Session class.
objSession = ObjectClrNew("WinSCP.Session" )
;Define Log File
objSession.SessionLogPath = webCashDRLog
;Open session
objSession.Open(objSessionOptions)
; Synchronize Directories
bFalse = ObjectType( 'BOOL', 0 )
bTrue = ObjectType( 'BOOL', 1 )
objMode = ObjectClrNew( 'WinSCP.SynchronizationMode' )
modeRemote = ObjectClrType( 'WinSCP.SynchronizationMode', objMode.Remote ) ; Only the remote directory is modified.
objCriteria = ObjectClrNew( 'WinSCP.SynchronizationCriteria' )
criteriaTime = ObjectClrType( 'WinSCP.SynchronizationCriteria', objCriteria.Time ) ; File times are compared to determine which is newer.
objTransferOptions = ObjectClrNew( 'WinSCP.TransferOptions' )
objTransferMode = ObjectClrNew( 'WinSCP.TransferMode' )
objTransferOptions.TransferMode = ObjectClrType( 'WinSCP.TransferMode', objTransferMode.Binary )
objTransferOptions.PreserveTimestamp = bFalse
;** Synchronize with SFTP server.
SynchronizationResult = objSession.SynchronizeDirectories( modeRemote, LocalPath, remotePath, bTrue, bFalse, criteriaTime, objTransferOptions)
; Disconnect, clean up
objSession.Dispose()
objCriteria = 0
objTransferMode = 0
objTransferOptions = 0
objSession = 0
objProtocol = 0
objSessionOptions = 0
transferOptions.PreserveTimestamp = false
should be enough. But obviously it is not applied, see "Preserving timestamp". Do you pass the transferOptions
to the Session.PutFiles
method? Please show your full code.
SynchronizeDirectories
code:
. 2014-03-20 13:27:32.206 Preserving timestamp [2014-03-19T19:51:43.000Z]
< 2014-03-20 13:27:32.206 Type: SSH_FXP_STATUS, Size: 44, Number: 1545
< 2014-03-20 13:27:32.206 Status code: 8, Message: 1545, Server: SSHServerAPI.SFTP.fxp_attrs, Language:
* 2014-03-20 13:27:32.206 (ETerminal) The server does not support the operation.
* 2014-03-20 13:27:32.206 Error code: 8
* 2014-03-20 13:27:32.206 Error message from server: SSHServerAPI.SFTP.fxp_attrs
. 2014-03-20 13:27:32.207 Asking user:
. 2014-03-20 13:27:32.207 **Upload of file 'test123.txt' was successful, but error occurred while setting the permissions and/or timestamp.**
. 2014-03-20 13:27:32.207
. 2014-03-20 13:27:32.207 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option. ("The server does not support the operation.
. 2014-03-20 13:27:32.207 Error code: 8
. 2014-03-20 13:27:32.207 Error message from server: SSHServerAPI.SFTP.fxp_attrs")
< 2014-03-20 13:27:32.207 Script: Upload of file 'test123.txt' was successful, but error occurred while setting the permissions and/or timestamp.
< 2014-03-20 13:27:32.207 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
< 2014-03-20 13:27:32.208 Script: The server does not support the operation.
< 2014-03-20 13:27:32.208 Error code: 8
< 2014-03-20 13:27:32.208 Error message from server: SSHServerAPI.SFTP.fxp_attrs
* 2014-03-20 13:27:32.212 (EScpSkipFile) **Upload of file 'test123.txt' was successful, but error occurred while setting the permissions and/or timestamp.**
* 2014-03-20 13:27:32.212
* 2014-03-20 13:27:32.212 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
* 2014-03-20 13:27:32.212 The server does not support the operation.
* 2014-03-20 13:27:32.212 Error code: 8
* 2014-03-20 13:27:32.212 Error message from server: SSHServerAPI.SFTP.fxp_attrs
. 2014-03-20 13:27:32.212 Script: Failed
> 2014-03-20 13:27:32.714 Script: exit
. 2014-03-20 13:27:32.714 Script: Exit code: 1
. 2014-03-20 13:27:32.714 Closing connection.
. 2014-03-20 13:27:32.714 Sending special code: 12
. 2014-03-20 13:27:32.714 Sent EOF message
transferOptions.PreserveTimestamp = false;
transferOptions.FilePermissions = null;
WinSCP.SessionRemoteException: Upload of file 'test.txt' was successful, but error occurred while setting the permissions and/or timestamp. If the problem persists, turn on 'Ignore permission errors' option. ---> WinSCP.SessionRemoteException: Permission denied.