Search code examples
batch-filearcgis

Prevent batch-file terminating early following a call to a third party CLI command


I'm trying to automate the creation of some boiler plate code using calls to a third party CLI (ArcGIS Enterprise Custom Data Feed) with a batch file. However, once the call to the first CLI command cdf createapp <app name> completes, the batch file exits, and so the rest of the script is not executed.

The call to createapp is doing what it should, but then it seemingly returns something which causes the batch file to stop at that point. Is there a way to handle this to stop this from happening?

I've tried putting the CLI commands in their own separate batch files and then calling them from the original batch file, but this didn't help.

Code snippet below:

The script just stops after the successful execution of cdf createapp, with no error message.

@echo off
echo Start of create cdpk script
echo ---------------------------
set cdf-app-name=%1
set data-provider-name=%2
echo Supplied arguments cdf-app-name=%cdf-app-name%, data-provider-name=%data-provider-name%
echo Creating new cdf app (%cdf-app-name%)...
cdf createapp %cdf-app-name%
cd %cdf-app-name%
echo Creating new cdf provider (%data-provider-name%)...
cdf createprovider %data-provider-name%
cd providers\%data-provider-name%
echo Installing packages (ws, node-fetch, uuid)...
npm install [email protected]
npm install [email protected]
npm install [email protected]
cd ..\..\..\
echo Copying source files (constructGeoJSON.js, model.js)...
 

Solution

  • Thanks for all the valuable feedback. Actually the first comment by magoo did the trick, namely adding CALL before the cdf calls. But the rest was very handy to learn. echooff was something that had happened with the copy paste, it was echo off in the script Mofi. Also, I'd created a little confusion by saying I'd tried splitting out calls in separate batch files. The code was the original single batch file solution.

    @echo off
    echo Start of create cdpk script
    echo ---------------------------
    set cdf-app-name=%~1
    set data-provider-name=%~2
    echo Supplied arguments cdf-app-name=%cdf-app-name%, data-provider-name=%data-provider-name%
    echo Creating new cdf app (%cdf-app-name%)...
    call cdf.cmd createapp %cdf-app-name%
    cd %cdf-app-name%
    echo Creating new cdf provider (%data-provider-name%)...
    call cdf.cmd createprovider %data-provider-name%
    cd providers\%data-provider-name%
    echo Installing packages (ws, node-fetch, uuid)...
    call npm.cmd install [email protected]
    call npm.cmd install [email protected]
    call npm.cmd install [email protected]
    cd ..\..\..\
    echo Copying source files (constructGeoJSON.js, model.js)...