Reputation: 1363
I'm developing an angular-android application, so I have to run some commands in the cmd. My system has minimal specifications since the commands take some time to run, I have to keep on monitoring it. To reduce the time and concentrate on my other things I put some command in the batch file. For example
ng build
cordova clean browser
cordova build browser
cordova run browser
I put the above commands and save it as a batch file. When I run this file it only executes first command ng build
, it doesn't automatically jump to second line. Previously I used mac, in that I save these as .sh
file and when I execute them, all the command inside that executed successfully. What should I do to execute next commands automatically in the batch file? Thank you.
Upvotes: 1
Views: 4449
Reputation: 2565
Some like this:
@echo off && setlocal enabledelayedexpansion
call ng &&^
call cordova clean browser &&^
call cordova build browser &&^
call cordova run browser
endlocal && goto :EOF
rem :: or in one line ::
call ng && (call cordova clean browser && (call cordova build browser &&(call cordova run browser)))
@echo off && setlocal enabledelayedexpansion
set "_run=ok"
call ng && for %%i in ("clean browser","build browser","run browser
)do if "!_run!" == "ok" call cordova %%~i || set "_run="
endlocal && goto :EOF
In bat/cmd you can use the &, |, && and || operator, also combine them...
commandA & commandB Run commandA and then run commandB commandA && commandB Run commandA, if it succeeds then run commandB commandA || commandB Run commandA, if it fails then run commandB commandA && commandB || commandC If commandA succeeds run commandB, if it fails commandC
Operator/Syntax Redirection in bat/cmd
Upvotes: 3
Reputation: 623
add start before each of those commands
start ng build
start cordova clean browser
start cordova build browser
start cordova run browser
Upvotes: 0