Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

teslatradeup

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

Ok that's great. I'll give this a shot and update the thread.

Thanks Martin!
martin

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
teslatradeup

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