user3266599
user3266599

Reputation: 19

Waiting for a process to complete in Batch file

I have some bat-file

@echo off
call git clone ssh://username@localhost/~/repo/site C:\git\project
:end

How I can get callback on success cloned project and start next terminal-program?

Or I need used something another, may be PowerShell?

Upvotes: 0

Views: 513

Answers (2)

henrycarteruk
henrycarteruk

Reputation: 13227

In poweshell you can can call the command and then check the $lastexitcode variable, if the command completed it will be 0 if it failed it will be 1. Using a simple if you can deal with this as below:

call git clone ssh://username@localhost/~/repo/site C:\git\project

if ($lastexitcode) {
    Write-Host "Failed"
    #error handling code here
}
else {
    Write-Host "Completed"
}

Upvotes: 1

Matt Douhan
Matt Douhan

Reputation: 2113

you can use ERRORLEVEL to see if last command failed or not

like this

if %ERRORLEVEL% == 0 GOTO continue
if %ERRORLEVEL% == 1 GOTO error

:continue
    echo do what you want here after successfully cloned
    goto exit

:error
    echo do your error handling here

:exit

Upvotes: 2

Related Questions