Cannot overwrite remote file

Advertisement

snakyjake
Joined:
Posts:
5

Cannot overwrite remote file

Error Message:
Cannot overwrite remote file
Using PowerShell and WinSCP.dll.

How can I script WinSCP to overwrite remote files on upload/put using PowerShell?

Is there a transfer option?
Or what is a simple PowerShell script to delete remote file if exists?

Thanks,
Jake

Reply with quote

Advertisement

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

Re: Cannot overwrite remote file

WinSCP overwrites remote files by default.

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

To generate 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

snakyjake
Joined:
Posts:
5

I'm getting permission denied.
I also get buffer optimization messages and "0 seconds" messages.

There have been some other issues around preserving timestamps (which I have set to false, and can't do true...not sure why).
I've tried various SendBuf sizes, and it doesn't change the buffer optimization message.
Not sure where I can change the "timeout=0" parameter. My sessionOptions.Timeout=15, not 0.

I don't have problems using the GUI, just from PowerShell. It would be nice to use the same GUI config in my PowerShell, and I'm checking to see if this can be done.

Partial Log:
. 2015-11-20 10:38:16.749 WinSCP Version 5.7.6 (Build 5874) (OS 6.1.7601 Service Pack 1 - Windows 7 Enterprise)
. 2015-11-20 10:38:16.753 Script: Retrospectively logging previous script records:
> 2015-11-20 10:38:16.753 Script: option batch on
< 2015-11-20 10:38:16.753 Script: batch           on        
< 2015-11-20 10:38:16.753 Script: reconnecttime   120       
> 2015-11-20 10:38:16.753 Script: option confirm off
< 2015-11-20 10:38:16.753 Script: confirm         off       
> 2015-11-20 10:38:16.753 Script: option reconnecttime 120
< 2015-11-20 10:38:16.753 Script: reconnecttime   120 
> 2015-11-20 10:38:16.753 Script: open sftp://{removed} -hostkey="{removed}" -timeout=0  
. 2015-11-20 10:38:16.754 Tunnel: No
. 2015-11-20 10:38:16.754 Transfer Protocol: SFTP
. 2015-11-20 10:38:16.754 Ping type: -, Ping interval: 30 sec; Timeout: 0 sec
. 2015-11-20 10:38:16.754 Disable Nagle: No
. 2015-11-20 10:38:16.754 Proxy: none
. 2015-11-20 10:38:16.754 Send buffer: 262144
. 2015-11-20 10:38:16.755 SSH protocol version: 2; Compression: No
. 2015-11-20 10:38:16.755 Bypass authentication: No
. 2015-11-20 10:38:16.755 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2015-11-20 10:38:16.755 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2015-11-20 10:38:16.755 KEX: dh-gex-sha1,dh-group14-sha1,dh-group1-sha1,rsa,WARN
. 2015-11-20 10:38:16.755 SSH Bugs: A,A,A,A,A,A,A,A,A,A,A,A
. 2015-11-20 10:38:16.755 Simple channel: Yes
. 2015-11-20 10:38:16.755 Return code variable: Autodetect; Lookup user groups: A
. 2015-11-20 10:38:16.755 Shell: default
. 2015-11-20 10:38:16.755 EOL: 0, UTF: 2
. 2015-11-20 10:38:16.755 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2015-11-20 10:38:16.755 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2015-11-20 10:38:16.755 SFTP Bugs: A,A
. 2015-11-20 10:38:16.755 SFTP Server: default
. 2015-11-20 10:38:16.755 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2015-11-20 10:38:16.755 Cache directory changes: Yes, Permanent: Yes
. 2015-11-20 10:38:16.755 DST mode: 1
. 2015-11-20 10:38:16.756 --------------------------------------------------------------------------
. 2015-11-20 10:38:16.756 Looking up host "{removed}"
. 2015-11-20 10:38:16.820 Connecting to {removed} port 22
. 2015-11-20 10:38:16.884 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:16.884 Asking user:
. 2015-11-20 10:38:16.884 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:16.885 
. 2015-11-20 10:38:16.885 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:17.385 Data has arrived, closing query to user.
. 2015-11-20 10:38:17.385 Server version: SSH-2.0-9.99 sshlib: 7.5.1.0
. 2015-11-20 10:38:17.385 Using SSH protocol version 2
. 2015-11-20 10:38:17.385 We claim version: SSH-2.0-WinSCP_release_5.7.6
. 2015-11-20 10:38:17.386 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:17.386 Asking user:
. 2015-11-20 10:38:17.386 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:17.386 
. 2015-11-20 10:38:17.386 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:17.887 Data has arrived, closing query to user.
. 2015-11-20 10:38:17.887 Doing Diffie-Hellman group exchange
. 2015-11-20 10:38:17.888 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:17.888 Asking user:
. 2015-11-20 10:38:17.888 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:17.888 
. 2015-11-20 10:38:17.888 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:18.389 Data has arrived, closing query to user.
. 2015-11-20 10:38:18.389 Doing Diffie-Hellman key exchange with hash SHA-1
. 2015-11-20 10:38:18.445 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:18.446 Asking user:
. 2015-11-20 10:38:18.446 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:18.446 
. 2015-11-20 10:38:18.446 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:18.948 Data has arrived, closing query to user.
. 2015-11-20 10:38:19.030 Verifying host key dss {removed}
. 2015-11-20 10:38:19.031 Host key matches configured key
. 2015-11-20 10:38:19.031 Host key fingerprint is:
. 2015-11-20 10:38:19.031 ssh-dss {removed}
. 2015-11-20 10:38:19.032 Initialised AES-256 SDCTR client->server encryption
. 2015-11-20 10:38:19.032 Initialised HMAC-SHA1 client->server MAC algorithm
. 2015-11-20 10:38:19.032 Initialised AES-256 SDCTR server->client encryption
. 2015-11-20 10:38:19.032 Initialised HMAC-SHA1 server->client MAC algorithm
. 2015-11-20 10:38:19.032 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:19.032 Asking user:
. 2015-11-20 10:38:19.032 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:19.032 
. 2015-11-20 10:38:19.032 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:19.533 Data has arrived, closing query to user.
! 2015-11-20 10:38:19.533 Using username "{removed}".
. 2015-11-20 10:38:19.533 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:19.534 Asking user:
. 2015-11-20 10:38:19.534 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:19.534 
. 2015-11-20 10:38:19.534 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:20.036 Data has arrived, closing query to user.
. 2015-11-20 10:38:20.037 Prompt (password, "SSH password", <no instructions>, "&Password: ")
. 2015-11-20 10:38:20.038 Using stored password.
. 2015-11-20 10:38:20.039 Sent password
. 2015-11-20 10:38:20.039 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:20.039 Asking user:
. 2015-11-20 10:38:20.039 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:20.039 
. 2015-11-20 10:38:20.039 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:20.541 Data has arrived, closing query to user.
. 2015-11-20 10:38:20.541 Access granted
. 2015-11-20 10:38:20.541 Opening session as main channel
. 2015-11-20 10:38:20.541 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:20.541 Asking user:
. 2015-11-20 10:38:20.541 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:20.542 
. 2015-11-20 10:38:20.542 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:21.042 Data has arrived, closing query to user.
. 2015-11-20 10:38:21.042 Opened main channel
. 2015-11-20 10:38:21.042 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:21.043 Asking user:
. 2015-11-20 10:38:21.043 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:21.043 
. 2015-11-20 10:38:21.043 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:21.544 Data has arrived, closing query to user.
. 2015-11-20 10:38:21.544 Started a shell/command
. 2015-11-20 10:38:21.544 --------------------------------------------------------------------------
. 2015-11-20 10:38:21.544 Using SFTP protocol.
. 2015-11-20 10:38:21.545 Doing startup conversation with host.
> 2015-11-20 10:38:21.546 Type: SSH_FXP_INIT, Size: 5, Number: -1
. 2015-11-20 10:38:21.546 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:21.546 Asking user:
. 2015-11-20 10:38:21.546 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:21.546 
. 2015-11-20 10:38:21.546 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:22.047 Data has arrived, closing query to user.
< 2015-11-20 10:38:22.047 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2015-11-20 10:38:22.047 SFTP version 3 negotiated.
. 2015-11-20 10:38:22.047 We believe the server has signed timestamps bug
. 2015-11-20 10:38:22.047 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 string are not mandatory
. 2015-11-20 10:38:22.048 Getting current directory name.
. 2015-11-20 10:38:22.048 Getting real path for '.'
> 2015-11-20 10:38:22.048 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
. 2015-11-20 10:38:22.048 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:22.048 Asking user:
. 2015-11-20 10:38:22.048 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:22.048 
. 2015-11-20 10:38:22.048 Wait for another 0 seconds?** ()
. 2015-11-20 10:38:22.549 Data has arrived, closing query to user.
< 2015-11-20 10:38:22.549 Type: SSH_FXP_NAME, Size: 89, Number: 16
. 2015-11-20 10:38:22.549 Real path is '{removed}'
. 2015-11-20 10:38:22.550 Startup conversation with host finished.
< 2015-11-20 10:38:22.550 Script: Active session: [1] {removed}
> 2015-11-20 10:38:22.727 Script: pwd
< 2015-11-20 10:38:22.727 Script: {removed}
> 2015-11-20 10:38:22.855 Script: stat -- "{removed}"
. 2015-11-20 10:38:22.855 Listing file "{removed}".
> 2015-11-20 10:38:22.855 Type: SSH_FXP_LSTAT, Size: 67, Number: 263
. 2015-11-20 10:38:22.856 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:22.856 Asking user:
. 2015-11-20 10:38:22.856 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:22.856 
. 2015-11-20 10:38:22.856 Wait for another 0 seconds?** ()
< 2015-11-20 10:38:22.856 Script: Host is not communicating for more than 0 seconds.
< 2015-11-20 10:38:22.857 Still waiting...
< 2015-11-20 10:38:22.857 Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
< 2015-11-20 10:38:22.857 Warning: Aborting this operation will close connection!
. 2015-11-20 10:38:23.358 Data has arrived, closing query to user.
< 2015-11-20 10:38:23.358 Type: SSH_FXP_ATTRS, Size: 37, Number: 263
. 2015-11-20 10:38:23.358 Academics.zip;-;314923;2015-11-20T18:34:41.000Z;"" [0];"" [0];rwxrwxrwx;1
< 2015-11-20 10:38:23.358 Script: -rwxrwxrwx   0                      314923 Nov 20 10:34:41 2015 {removed}
> 2015-11-20 10:38:23.360 Script: put  -nopermissions -nopreservetime -transfer="binary" -resumesupport="off" -- {removed}
. 2015-11-20 10:38:23.362 Copying 1 files/directories to remote directory "Test Data/"
. 2015-11-20 10:38:23.362   PrTime: No; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: N (102400); CalcS: Yes; Mask: 
. 2015-11-20 10:38:23.362   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
. 2015-11-20 10:38:23.362   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2015-11-20 10:38:23.363 File: '{removed}' [2015-11-20T18:02:57.748Z] [314923]
. 2015-11-20 10:38:23.364 Copying "{removed}" to remote directory started.
. 2015-11-20 10:38:23.366 Binary transfer mode selected.
. 2015-11-20 10:38:23.366 Opening remote file.
> 2015-11-20 10:38:23.366 Type: SSH_FXP_OPEN, Size: 83, Number: 515
. 2015-11-20 10:38:23.366 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:23.366 Asking user:
. 2015-11-20 10:38:23.366 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:23.367 
. 2015-11-20 10:38:23.367 Wait for another 0 seconds?** ()
< 2015-11-20 10:38:23.367 Script: Host is not communicating for more than 0 seconds.
< 2015-11-20 10:38:23.367 Still waiting...
< 2015-11-20 10:38:23.367 Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
< 2015-11-20 10:38:23.367 Warning: Aborting this operation will close connection!
. 2015-11-20 10:38:23.871 Data has arrived, closing query to user.
< 2015-11-20 10:38:23.871 Type: SSH_FXP_STATUS, Size: 36, Number: 515
< 2015-11-20 10:38:23.871 Status code: 3, Message: 515, Server: Permission denied, Language: en 
> 2015-11-20 10:38:23.871 Type: SSH_FXP_LSTAT, Size: 67, Number: 775
. 2015-11-20 10:38:23.871 Waiting for data timed out, asking user what to do.
. 2015-11-20 10:38:23.872 Asking user:
. 2015-11-20 10:38:23.872 **Host is not communicating for 0 seconds.
. 2015-11-20 10:38:23.872 
. 2015-11-20 10:38:23.872 Wait for another 0 seconds?** ()
< 2015-11-20 10:38:23.872 Script: Host is not communicating for more than 0 seconds.
< 2015-11-20 10:38:23.872 Still waiting...
< 2015-11-20 10:38:23.872 Note: If the problem repeats, try turning off 'Optimize connection buffer size'.
< 2015-11-20 10:38:23.872 Warning: Aborting this operation will close connection!
. 2015-11-20 10:38:24.373 Data has arrived, closing query to user.
< 2015-11-20 10:38:24.373 Type: SSH_FXP_ATTRS, Size: 37, Number: 775
* 2015-11-20 10:38:24.373 (ETerminal) Permission denied.
* 2015-11-20 10:38:24.373 Error code: 3
* 2015-11-20 10:38:24.373 Error message from server (en): Permission denied
. 2015-11-20 10:38:24.374 Asking user:
. 2015-11-20 10:38:24.374 Cannot overwrite remote file '{removed}'.$$
. 2015-11-20 10:38:24.374  
. 2015-11-20 10:38:24.374 Press 'Delete' to delete the file and create new one instead of overwriting it.$$ ("Permission denied.
. 2015-11-20 10:38:24.374 Error code: 3
. 2015-11-20 10:38:24.374 Error message from server (en): Permission denied")
< 2015-11-20 10:38:24.374 Script: Cannot overwrite remote file '{removed}'.
< 2015-11-20 10:38:24.376 Script: Permission denied.
< 2015-11-20 10:38:24.376 Error code: 3
< 2015-11-20 10:38:24.376 Error message from server (en): Permission denied
* 2015-11-20 10:38:24.378 (EScpSkipFile) Cannot overwrite remote file '{removed}'.$$
* 2015-11-20 10:38:24.378  
* 2015-11-20 10:38:24.378 Press 'Delete' to delete the file and create new one instead of overwriting it.$$
* 2015-11-20 10:38:24.378 Permission denied.
* 2015-11-20 10:38:24.378 Error code: 3
* 2015-11-20 10:38:24.378 Error message from server (en): Permission denied
. 2015-11-20 10:38:24.378 Script: Failed
> 2015-11-20 10:38:24.890 Script: exit
. 2015-11-20 10:38:24.890 Script: Exit code: 1
. 2015-11-20 10:38:24.890 Closing connection.
. 2015-11-20 10:38:24.890 Sending special code: 12
. 2015-11-20 10:38:24.891 Sent EOF message

Reply with quote

martin
Site Admin
martin avatar

Show us your code and GUI log file for comparison.
But you cannot remove the paths, the logs are useless then.
Attach them as a private, if you do not want the paths to be publicly visible.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum