Batch does not wait for WinSCP FTP script to complete before going to next sommand

Advertisement

teslatradeup
Joined:
Posts:
2
Location:
Ottawa

Batch does not wait for WinSCP FTP script to complete before going to next sommand

Hi,

I have an issue with a batch program. When I call WinSCP to run a command script file, the batch file does not wait for WinSCP to complete it's tasks prior to going to the next command.

Here is how I'm calling WinSCP and running the FTP script:
start winscp.exe /ini=F:\Axios\Test\Automations\Common\EDB_Transfer\WinSCP\WinSCP.ini /command script=F:\Axios\Test\Automations\Common\EDB_Transfer\edb_upload.ftp /parameter ftp.server.my myusername password localfolder destinationftpfolder /Log=F:\Axios\Test\Automations\Common\EDB_Transfer\Logs\FTP_Logs\edb_upload_20220210.log

Here is the script that's being run:
# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
# Connect
open %2%:%3%@%1%
 
put -nopreservetime
 
# Change remote directory
# Force binary mode transfer
option transfer binary
# Copy file to the SFTP directory 
synchronize remote -filemask="*.pgp*" %4% %5% -delete 
 
# Disconnect
close
exit
If you look at the attached image, you can see that the start WinSCP command finished at 11:24.33.15, however, my FTP script was still running and received a connection error at 11:24:43.281.

Am I missing something?

Thank you, and I appreciate the help.

Cheers.
Martin

2022-02-10_11-25-09.png

Reply with quote

Advertisement

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

Re: Batch does not wait for WinSCP FTP script to complete before going to next sommand

The very purpose of the Windows start command is to start something in a different window and do not wait for it.
If you want to wait, remove the start command.

And in batch file you should use winscp.com instead of winscp.exe.
https://winscp.net/eng/docs/executables

Reply with quote

Advertisement

You can post new topics in this forum