Topic "Issues with Winscp PUT -Delete option"

Author Message
kumar.kk
[View user's profile]

Joined: 2014-12-15
Posts: 3
Hi,

I have the below script to transfer files to remote server(Unix) and then delete the files in the local directory. But once in a day we are seeing the below error.
"Script: System Error. Code: 2.
The system cannot find the file specified"
1 out of 100 files was not copied to the remote directory and is also being deleted from the local folder. can someone please help me to know if there is a way to NOT delete the file if it was not transferred to the remote server.

we are using WinSCP Version 5.1.7(Build 3446)

Here is the batch script that runs every one minute.
@echo off
start winscp /console /script="C:\CDI\SFTP.txt" /log=SFTP.Log

---------SFTP.txt-----------
option batch abort
option confirm off
open sftp://user:password@HostName -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:x:xx:xx:xx"
lcd C:\input\
cd inbound
option transfer binary
put -delete File_20141214230801099.txt
chmod 777 File_20141214230801099.txt
close
exit
---------*******-----------



Thanks
Kumar
LogFile.txt (7.67 KB) Private file

Description: Log File attached

Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
WinSCP does not delete the local file, if the upload fails.
So I actually believe the file did not exist already at the time the upload started, hence the error message.
_________________
Martin Prikryl
kumar.kk
[View user's profile]

Joined: 2014-12-15
Posts: 3
Thanks for the reply prikryl. we even tried to trigger the script only when the file is present in folder. we have this issue for only 1 or 2 files a day. Is there any other way to transfer files to remote server and delete the local files using batch script.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
kumar.kk wrote:
we even tried to trigger the script only when the file is present in folder.

How do your check that?
Isn't there any other process that might delete the file, after you test file existence, but before you run WinSCP?

Quote:
Is there any other way to transfer files to remote server and delete the local files using batch script.

Your code is correct, there's nothing to be done differently.
kumar.kk
[View user's profile]

Joined: 2014-12-15
Posts: 3
There is no other process to delete the file in the local directory except the SFTP script which has PUT -Delete option.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
I have sent you an email with a debug version of WinSCP to address you have used to register on this forum.
_________________
Martin Prikryl
matrixtan

Guest


What is the code to use?
My folder is name is SCB.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
matrixtan wrote:
What is the code to use?
My folder is name is SCB.

Please start here:
http://winscp.net/eng/docs/guide_automation
http://winscp.net/eng/docs/scriptcommand_rm
Advertisements

You can post new topics in this forum






Search Site

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