Delete of locked file fails, but winscp errorlevel is zero

Advertisement

ciove
Joined:
Posts:
9

Delete of locked file fails, but winscp errorlevel is zero

Bug description:
If source file at SFTP-server is locked (for example opened with MS-Word), and winscp-client tries to delete it, either with 'rm' command or with '-delete' option in 'get' command in a script, winscp.com does not show errormessage and does not increase errorlevel.

Version: winscp.com portable v. 3.0.0.127
Version of MS-Win: Windows 2003 Server R2 SP1
Server and protocol:
SFTP Server: CopSSH 1.4.5.2
Session protocol = SSH-2
SSH implementation = OpenSSH_5.0
Encryption algorithm = aes
Compression = ZLib
File transfer protocol = SFTP-3

I use scripting.
No error message.

The commandline and 'get -delete' script (sftp_test1.txt) and console output:

C:\mylocalfolder\bin>winscp.com /ini=winscp.ini /script=sftp_test1.txt /log=sftp_test1.xml
option batch on 
option confirm off 
option transfer binary 
open sftp://myaccount@myserver.mydomain.com:22 -privatekey=C:\mylocalfolder\keys\myserver.mydomain.com\myaccount\private_key.ppk -hostkey="ssh-rsa 1024 df:41:c3:32:a3:1c:d0:37:e3:b6:73:00:82:fa:5c:8d"
get -delete -preservetime ./testfile*.doc "\\mywinserver.myaddomain.com\myfolder\test\" 
ls ./testfile*.doc*
exit

C:\mylocalfolder\bin>dir>nul
C:\mylocalfolder\bin>winscp.com /ini=winscp.ini /script=sftp_test1.txt /log=sftp_test1.xml
batch on
confirm off
transfer binary
Searching for host...
Connecting to host...
Authenticating...
Using username "myaccount".
Authenticating with public key "rsa-key-20081125".
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] myaccount@myserver.mydomain.com
testfile1.doc | 23 KiB | 113,4 KiB/s | binary | 100%
-rw-r--r-- 1 myaccount None 24064 Jun 23 15:12:30 2011 testfile1.doc

C:\mylocalfolder\bin>Echo %errorlevel%
0

The commandline and 'rm' script (sftp_test2.txt) and console output:
C:\mylocalfolder\bin>winscp.com /ini=winscp.ini /script=sftp_test2.txt /log=sftp_test2.xml

option batch on 
option confirm off 
option transfer binary 
open sftp://myaccount@myserver.mydomain.com:22 -privatekey=C:\mylocalfolder\keys\myserver.mydomain.com\myaccount\private_key.ppk -hostkey="ssh-rsa 1024 df:41:c3:32:a3:1c:d0:37:e3:b6:73:00:82:fa:5c:8d"
rm ./testfile*.doc 
ls ./testfile*.doc*
exit

C:\mylocalfolder\bin>Echo %errorlevel%
0
C:\mylocalfolder\bin>winscp.com /ini=winscp.ini /script=sftp_test2.txt /log=sftp_test2.xml
batch on
confirm off
transfer binary
Searching for host...
Connecting to host...
Authenticating...
Using username "myaccount".
Authenticating with public key "rsa-key-20081125".
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] myaccount@myserver.mydomain.com
./testfile1.doc
-rw-r--r-- 1 myaccount None 24064 Jun 23 15:12:30 2011 testfile1.doc

C:\mylocalfolder\bin>Echo %errorlevel%
0

Reply with quote

Advertisement

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

Re: Delete of locked file fails, but winscp errorlevel is zero

Please post a full log file showing the problem.

To generate log file, enable logging, log in to your server and do the operation and only the operation that causes the error. For posting extensive logs you may use pastebin or similar application. 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 may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.

Reply with quote

ciove
Joined:
Posts:
9

Solved... kinda. A word of warning.

Hi,
I'm enclosing quote of Martin's email to me:

As you can see in the log, WinSCP requests removal of the file and the server replies with status code 0 (success). So there's no way for WinSCP to know that there's a problem.

. 2011-07-06 13:19:04.990 Deleting file "/cygdrive/x/MyAccount/testfile1.doc".
> 2011-07-06 13:19:04.990 Type: SSH_FXP_REMOVE, Size: 71, Number: 4621
...
< 2011-07-06 13:19:05.037 Type: SSH_FXP_STATUS, Size: 24, Number: 4621
< 2011-07-06 13:19:05.037 Status code: 0


So this means that from sftp-client's perspective the delete was ok, but actually it was not.

Here's the warning: If your script deletes file, there is small possibility, that the file is not actually deleted. You should take this into consideration when automating the transfers.

Reply with quote

Advertisement

You can post new topics in this forum