File overwrite working when I do not want to to.

Advertisement

rando1
Guest

File overwrite working when I do not want to to.

Hello,

I'd like to push a file to a remote directory, however, I would like to not overwrite the file if it exists. According to the documentation, when batch mode is set to ON any choice prompt is automatically replied negatively. When option confirm is ON it should toggle confirmation of an overwrite. Neither seem to work with my script below. When the file exists, it continues to overwrite without error. What am I missing?

Script:

option batch on
option confirm on
open sftp://RPayVendor:****@ftp.****.****.com
put "\\fs1\XXX.DAT" "XXX.OK"
close
exit

Log file:

. 2019-08-22 14:56:20.335 --------------------------------------------------------------------------
. 2019-08-22 14:56:20.335 WinSCP Version 5.13.5 (Build 8967) (OS 6.3.9600 - Windows Server 2012 R2 Standard)
. 2019-08-22 14:56:20.335 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\
. 2019-08-22 14:56:20.335 Log level: Normal
. 2019-08-22 14:56:20.335 Local account: ***\dm
. 2019-08-22 14:56:20.335 Working directory: C:\SS
. 2019-08-22 14:56:20.335 Process ID: 2108
. 2019-08-22 14:56:20.335 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console=5.13.5 /consoleinstance=_3976_162 "/script=C:\SS\pushmydata.txt"
. 2019-08-22 14:56:20.335 Time zone: Current: GMT-5, Standard: GMT-6 (Central Standard Time), DST: GMT-5 (Central Daylight Time), DST Start: 3/10/2019, DST End: 11/3/2019
. 2019-08-22 14:56:20.335 Login time: Thursday, August 22, 2019 2:56:20 PM
. 2019-08-22 14:56:20.335 --------------------------------------------------------------------------
. 2019-08-22 14:56:20.335 Script: Retrospectively logging previous script records:
> 2019-08-22 14:56:20.335 Script: option batch on
< 2019-08-22 14:56:20.335 Script: batch on
> 2019-08-22 14:56:20.335 Script: option confirm on
< 2019-08-22 14:56:20.335 Script: confirm on
> 2019-08-22 14:56:20.335 Script: open sftp://RPayVendor:***@ftp.****.****.com
. 2019-08-22 14:56:20.335 --------------------------------------------------------------------------
. 2019-08-22 14:56:20.335 Session name: RPayVendor@ftp.****.****.com (Ad-Hoc site)
. 2019-08-22 14:56:20.335 Host name: ftp.****.****.com (Port: 22)
. 2019-08-22 14:56:20.335 User name: RPayVendor (Password: Yes, Key file: No, Passphrase: No)
. 2019-08-22 14:56:20.335 Tunnel: No
. 2019-08-22 14:56:20.335 Transfer Protocol: SFTP
. 2019-08-22 14:56:20.335 Ping type: Off, Ping interval: 30 sec; Timeout: 15 sec
. 2019-08-22 14:56:20.335 Disable Nagle: No
. 2019-08-22 14:56:20.335 Proxy: None
. 2019-08-22 14:56:20.335 Send buffer: 262144
. 2019-08-22 14:56:20.335 SSH protocol version: 2; Compression: No
. 2019-08-22 14:56:20.335 Bypass authentication: No
. 2019-08-22 14:56:20.335 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: Yes
. 2019-08-22 14:56:20.335 GSSAPI: Forwarding: No; Libs: gssapi32,sspi,custom; Custom:
. 2019-08-22 14:56:20.335 Ciphers: aes,chacha20,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2019-08-22 14:56:20.335 KEX: ecdh,dh-gex-sha1,dh-group14-sha1,rsa,WARN,dh-group1-sha1
. 2019-08-22 14:56:20.335 SSH Bugs: Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto
. 2019-08-22 14:56:20.335 Simple channel: Yes
. 2019-08-22 14:56:20.335 Return code variable: Autodetect; Lookup user groups: Auto
. 2019-08-22 14:56:20.335 Shell: default
. 2019-08-22 14:56:20.335 EOL: LF, UTF: Auto
. 2019-08-22 14:56:20.335 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes; Follow directory symlinks: No
. 2019-08-22 14:56:20.335 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2019-08-22 14:56:20.335 SFTP Bugs: Auto,Auto
. 2019-08-22 14:56:20.335 SFTP Server: default
. 2019-08-22 14:56:20.335 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2019-08-22 14:56:20.335 Cache directory changes: Yes, Permanent: Yes
. 2019-08-22 14:56:20.335 Recycle bin: Delete to: No, Overwritten to: No, Bin path:
. 2019-08-22 14:56:20.335 DST mode: Unix
. 2019-08-22 14:56:20.335 --------------------------------------------------------------------------
. 2019-08-22 14:56:20.335 Looking up host "ftp.****.****.com" for SSH connection
. 2019-08-22 14:56:20.351 Connecting to 207.**.**.** port 22
. 2019-08-22 14:56:20.398 We claim version: SSH-2.0-WinSCP_release_5.13.5
. 2019-08-22 14:56:20.429 Server version: SSH-2.0-CoreFTP-0.3.3
. 2019-08-22 14:56:20.429 Using SSH protocol version 2
. 2019-08-22 14:56:20.429 Have a known host key of type rsa2
. 2019-08-22 14:56:20.523 Doing Diffie-Hellman group exchange
. 2019-08-22 14:56:20.554 Doing Diffie-Hellman key exchange with hash SHA-256
. 2019-08-22 14:56:21.992 Host key fingerprint is:
. 2019-08-22 14:56:21.992 ssh-rsa 2048 07:fd:2a:6e:eb:08:b2:f5:53:**:11:e3:15:8*:e1:8* be1UJpj4Pulolw2+9/YuLBzQi7s6VTB9ePq1fL2gjds=
. 2019-08-22 14:56:21.992 Host key matches cached key
. 2019-08-22 14:56:21.992 Initialised AES-256 SDCTR client->server encryption
. 2019-08-22 14:56:21.992 Initialised HMAC-SHA-256 client->server MAC algorithm
. 2019-08-22 14:56:22.023 Initialised AES-256 SDCTR server->client encryption
. 2019-08-22 14:56:22.023 Initialised HMAC-SHA-256 server->client MAC algorithm
! 2019-08-22 14:56:22.054 Using username "RPayVendor".
. 2019-08-22 14:56:22.085 Server offered these authentication methods: password
. 2019-08-22 14:56:22.085 Prompt (password, "SSH password", <no instructions>, "&Password: ")
. 2019-08-22 14:56:22.085 Using stored password.
. 2019-08-22 14:56:22.101 Sent password
. 2019-08-22 14:56:22.226 Access granted
. 2019-08-22 14:56:22.226 Opening session as main channel
. 2019-08-22 14:56:22.257 Opened main channel
. 2019-08-22 14:56:22.398 Started a shell/command
. 2019-08-22 14:56:22.398 --------------------------------------------------------------------------
. 2019-08-22 14:56:22.398 Using SFTP protocol.
. 2019-08-22 14:56:22.398 Doing startup conversation with host.
> 2019-08-22 14:56:22.398 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2019-08-22 14:56:22.523 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2019-08-22 14:56:22.523 SFTP version 3 negotiated.
. 2019-08-22 14:56:22.523 We believe the server has signed timestamps bug
. 2019-08-22 14:56:22.523 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 strings are not mandatory
. 2019-08-22 14:56:22.523 Getting current directory name.
. 2019-08-22 14:56:22.523 Getting real path for '.'
> 2019-08-22 14:56:22.523 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2019-08-22 14:56:22.554 Type: SSH_FXP_NAME, Size: 23, Number: 16
. 2019-08-22 14:56:22.554 Real path is '/'
. 2019-08-22 14:56:22.554 Startup conversation with host finished.
< 2019-08-22 14:56:22.554 Script: Active session: [1] RPayVendor:****@ftp.****.****.com
> 2019-08-22 14:56:22.554 Script: put "\\fs1\BANK.DAT" "BANK.OK"
. 2019-08-22 14:56:22.554 Copying 1 files/directories to remote directory "/" - total size: 72,568
. 2019-08-22 14:56:22.554 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask: BANK.OK
. 2019-08-22 14:56:22.554 TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
. 2019-08-22 14:56:22.554 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2019-08-22 14:56:22.554 Getting real path for '/'
> 2019-08-22 14:56:22.554 Type: SSH_FXP_REALPATH, Size: 10, Number: 272
< 2019-08-22 14:56:22.601 Type: SSH_FXP_NAME, Size: 23, Number: 272
. 2019-08-22 14:56:22.601 Real path is '/'
. 2019-08-22 14:56:22.601 File: '\\fs1\BANK.DAT' [2019-08-22T19:35:05.007Z] [72568]
. 2019-08-22 14:56:22.601 Copying "\\fs1\BANK.DAT" to remote directory started.
. 2019-08-22 14:56:22.601 Binary transfer mode selected.
. 2019-08-22 14:56:22.601 Opening remote file.
> 2019-08-22 14:56:22.601 Type: SSH_FXP_OPEN, Size: 33, Number: 515
< 2019-08-22 14:56:22.632 Type: SSH_FXP_HANDLE, Size: 23, Number: 515
> 2019-08-22 14:56:22.632 Type: SSH_FXP_WRITE, Size: 32764, Number: 1030
. 2019-08-22 14:56:22.663 2 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2019-08-22 14:56:22.663 Type: SSH_FXP_CLOSE, Size: 23, Number: 1796
> 2019-08-22 14:56:22.663 Type: SSH_FXP_SETSTAT, Size: 29, Number: 777
< 2019-08-22 14:56:22.788 Type: SSH_FXP_STATUS, Size: 24, Number: 1030
< 2019-08-22 14:56:22.788 Status code: 0
< 2019-08-22 14:56:22.882 Type: SSH_FXP_STATUS, Size: 24, Number: 1286
< 2019-08-22 14:56:22.882 Status code: 0
< 2019-08-22 14:56:22.882 Type: SSH_FXP_STATUS, Size: 24, Number: 1542
< 2019-08-22 14:56:22.882 Status code: 0
< 2019-08-22 14:56:22.882 Type: SSH_FXP_STATUS, Size: 24, Number: 1796
< 2019-08-22 14:56:22.882 Status code: 0
. 2019-08-22 14:56:22.882 Preserving timestamp [2019-08-22T19:35:05.000Z]
< 2019-08-22 14:56:22.882 Type: SSH_FXP_STATUS, Size: 24, Number: 777
< 2019-08-22 14:56:22.882 Status code: 0
. 2019-08-22 14:56:22.882 Transfer done: '\\fs1\XXX.DAT' => '/XXX.OK' [72568]
. 2019-08-22 14:56:22.882 Copying finished: Transferred: 72,568, Elapsed: 0:00:00, CPS: 170,252/s
> 2019-08-22 14:56:22.882 Script: close
. 2019-08-22 14:56:22.882 Closing connection.
. 2019-08-22 14:56:22.882 Sending special code: 12
. 2019-08-22 14:56:22.882 Sent EOF message

Reply with quote

Advertisement

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

Re: File overwrite working when I do not want to to.

For me it works the way you want.
Do overwrite confirmations work for you in WinSCP GUI against the same server?

Reply with quote

Rrando1
Guest

No, it does not confirm the overwrite on the GUI either. Could it be a permissions issue on my end or their end?

Reply with quote

martin
Site Admin
martin avatar

A verbose (log level Debug 1) can show more, if you want us to investigate. But I'm positive that it's a bug in the SFTP server.

Reply with quote

Advertisement

You can post new topics in this forum