WinSCP batch - file transfer happens sometimes only

Advertisement

kiran teki
Joined:
Posts:
5

WinSCP batch - file transfer happens sometimes only

My requirement is
>> sftp files from source to destination
>> move files to backup location in source itself

So I have installed WinSCP and its working properly. Based on this I generated the batch script which is also executing without error but file transfer happens sometime only. Surprising GUI is working as expected but this is not, What could be the issue ? Need urgent fix would be much appreciated as nearing delivery deadlines.
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\sftp\logs\sftp_log.log" /ini=nul ^
  /command ^
    "open sftp://xxxxxxxxx/ -hostkey=""ssh-ed25519 256 d7Te2DHmvBNSWJNBWik2KbDTjmWtYHe2bvXTMM9lVg4=""" ^
    "cd /IN" ^
    "put *.*" ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%

Reply with quote

Advertisement

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

Re: WinSCP batch - file transfer happens sometimes only

Please attach a full session log file showing the problem (using the latest version of WinSCP). Please include a log file both from a successful and a failed session.

Reply with quote

kiran teki
Joined:
Posts:
5

Re: WinSCP batch - file transfer happens sometimes only

martin wrote:

Please attach a full session log file showing the problem (using the latest version of WinSCP). Please include a log file both from a successful and a failed session.

Great to see your reply. Come to the issue we are using latest WinSCP 5.15.5(Build 9925) version. And I attached latest log please have a look.

Thanks,
Kiran Teki.

Reply with quote

kiran teki
Joined:
Posts:
5

Re: WinSCP batch - file transfer happens sometimes only

::::Update:::::
No issue with script, destination server receives file properly, we received update from that team that they run other back end job for every 1 minute to moves these file to other location immediately.
Now we auto triggered this script with windows task scheduler then another issue comes into picture, batch job triggering properly as per log data but not transferring the files.

Bottom line is manual trigger working properly but not automated one
Please help us out on this.


Thanks,
Kiran Teki.

Reply with quote

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

Re: WinSCP batch - file transfer happens sometimes only

kiran teki wrote:

Bottom line is manual trigger working properly but not automated one
Please help us out on this.
Again, post a log file please.

Reply with quote

Advertisement

kiran teki
Joined:
Posts:
5

Re: WinSCP batch - file transfer happens sometimes only

martin wrote:

kiran teki wrote:

Bottom line is manual trigger working properly but not automated one
Please help us out on this.
Again, post a log file please.

Please find the logs herewith.

Reply with quote

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

Re: WinSCP batch - file transfer happens sometimes only

You are starting WinSCP with C:\Windows\system32 as the startup/working directory and you try to upload files *.csv from there. It's no surprise that there are no such files.

. 2019-11-27 14:55:00.142 Working directory: C:\Windows\system32
...
> 2019-11-27 15:00:02.366 Script: put *.csv
< 2019-11-27 15:00:02.366 Script: No file matching '*.csv' found.
Either set the startup directory to the folder where you files are; or use lcd command before put to change the working directory to that folder. Or use a full source path in the put command.

Reply with quote

kiran teki
Joined:
Posts:
5

Re: WinSCP batch - file transfer happens sometimes only

martin wrote:

You are starting WinSCP with C:\Windows\system32 as the startup/working directory and you try to upload files *.csv from there. It's no surprise that there are no such files.

. 2019-11-27 14:55:00.142 Working directory: C:\Windows\system32
...
> 2019-11-27 15:00:02.366 Script: put *.csv
< 2019-11-27 15:00:02.366 Script: No file matching '*.csv' found.
Either set the startup directory to the folder where you files are; or use lcd command before put to change the working directory to that folder. Or use a full source path in the put command.

Perfect it worked well after I gave the full path in PUT command , now transferring the files automatically without any issue. I have a last query 'Can we rotate the logs based on size/date ?'

Thanks,
Kiran Teki.

Reply with quote

Advertisement

You can post new topics in this forum