5
2
I have a very specific requirement. I am attempting to upload files via sftp which uses private keys. I already have a bat file that connects to the host and uploads the file however I need to move the uploaded files once completed to another path.
The first bat file is called start.bat
. This connects to the sftp server and uploads the file. I am using winscp to connect to the host.
The second bat file is called done.bat
. This moves files from one directory to another.
I am calling the second bat file from the first using call done.bat
. The issue I have is that done.bat
is completed even before the first batch file has had the chance to authenticate, login and upload.
I want to only move the file once the upload has completed. If the upload fails for some reason, the second file doesn't execute.
The bat files are on a Windows XP machine.
I do not understand a point of this answer. Actually even of the question. When you execute a program from a batch file, the batch file waits for it to complete. No need for
– Martin Prikryl – 2017-06-16T05:59:15.517start /wait
. See also Why GUI application blocks a batch file?.You can use winscp.com rather than winscp.exe to have WinSCP wait in a batch file as you'd expect... – Ian Yates – 2019-10-29T01:46:09.487
I was assuming winscp.exe being called from a batch file wouldn't return until it was done in the first place. If that's not the case, then you instead have to do other things like see whether or not you can get winscp.exe to log to a file, use the ping 127.0.0.1 pause trick to give it 5 minutes or whatever, then look at the log to check for success/failure, etc. – Mark Allen – 2012-08-24T19:44:53.747
@Mark Allen - Could you elaborate? Don't quite follow what you mean. – PeanutsMonkey – 2012-08-24T20:05:49.780