Hello everybody,
I am trying to execute three commands in one go in cmd.exe, i.e.:
cd C:\xy & SDKShell & where ogr2ogr
i.e. I am changing to the directory where a file "SDKShell.bat" lies, execute it, then I want to execute some other command. Unfortunately, the execution of the line stops after the execution of the bat-file. This code is just an example for a little more complicated stuff I want to do (the *.bat is setting the environment (variables) for the third command), so just typing "where ogr2ogr" after the execution of the bat is not an option. So my questions are:
1. is it possible at all to include a *.bat in such a command chain?
2. maybe sth. must be changed in the *.bat file. This file looks as follows:
@echo off
if "%1" == "setenv" goto setenv
%comspec% /k %~dp0\SDKShell.bat setenv %1
goto exit
:setenv
@echo Setting environment for using the GDAL and MapServer tools.
if "%2"=="hideoci" goto hideoci
set ocipath=0
set _path="%PATH:;=" "%"
for %%p in (%_path%) do if not "%%~p"=="" if exist %%~p\oci.dll set ocipath=1
if "%ocipath%"=="0" goto hideoci
@echo WARNING: If you encounter problems with missing oci libraries then type:
@echo SDKShell hideoci
goto setenv2
:hideoci
@echo Hiding the OCI plugin library.
if not exist %~dp0\bin\gdal\plugins-optional mkdir %~dp0\bin\gdal\plugins-optional
if exist %~dp0\bin\gdal\plugins\ogr_OCI.dll move %~dp0\bin\gdal\plugins\ogr_OCI.dll %~dp0\bin\gdal\plugins-optional\ogr_OCI.dll
if exist %~dp0\bin\gdal\plugins\gdal_GEOR.dll move %~dp0\bin\gdal\plugins\gdal_GEOR.dll %~dp0\bin\gdal\plugins-optional\gdal_GEOR.dll
:setenv2
SET PATH=%~dp0\bin;%~dp0\bin\gdal\python\osgeo;%~dp0\bin\proj\apps;%~dp0\bin\gdal\apps;%~dp0\bin\ms\apps;%~dp0\bin\gdal\csharp;%~dp0\bin\ms\csharp;%~dp0\bin\curl;%PATH%
SET GDAL_DATA=%~dp0\bin\gdal-data
SET GDAL_DRIVER_PATH=%~dp0\bin\gdal\plugins
SET PYTHONPATH=%~dp0\bin\gdal\python\osgeo;%~dp0\bin\ms\python
SET PROJ_LIB=%~dp0\bin\proj\SHARE
:exit
Unfortunately I am a greenhorn when it comes to cmd commands and *.bat-files, so any help would be appreciated. Another option would be to rewrite the *bat in a way that all changes listed there are permanently. I have tried to do so (with setx, etc), but obviously I miss something.
regards,
Ludwig
I am trying to execute three commands in one go in cmd.exe, i.e.:
cd C:\xy & SDKShell & where ogr2ogr
i.e. I am changing to the directory where a file "SDKShell.bat" lies, execute it, then I want to execute some other command. Unfortunately, the execution of the line stops after the execution of the bat-file. This code is just an example for a little more complicated stuff I want to do (the *.bat is setting the environment (variables) for the third command), so just typing "where ogr2ogr" after the execution of the bat is not an option. So my questions are:
1. is it possible at all to include a *.bat in such a command chain?
2. maybe sth. must be changed in the *.bat file. This file looks as follows:
@echo off
if "%1" == "setenv" goto setenv
%comspec% /k %~dp0\SDKShell.bat setenv %1
goto exit
:setenv
@echo Setting environment for using the GDAL and MapServer tools.
if "%2"=="hideoci" goto hideoci
set ocipath=0
set _path="%PATH:;=" "%"
for %%p in (%_path%) do if not "%%~p"=="" if exist %%~p\oci.dll set ocipath=1
if "%ocipath%"=="0" goto hideoci
@echo WARNING: If you encounter problems with missing oci libraries then type:
@echo SDKShell hideoci
goto setenv2
:hideoci
@echo Hiding the OCI plugin library.
if not exist %~dp0\bin\gdal\plugins-optional mkdir %~dp0\bin\gdal\plugins-optional
if exist %~dp0\bin\gdal\plugins\ogr_OCI.dll move %~dp0\bin\gdal\plugins\ogr_OCI.dll %~dp0\bin\gdal\plugins-optional\ogr_OCI.dll
if exist %~dp0\bin\gdal\plugins\gdal_GEOR.dll move %~dp0\bin\gdal\plugins\gdal_GEOR.dll %~dp0\bin\gdal\plugins-optional\gdal_GEOR.dll
:setenv2
SET PATH=%~dp0\bin;%~dp0\bin\gdal\python\osgeo;%~dp0\bin\proj\apps;%~dp0\bin\gdal\apps;%~dp0\bin\ms\apps;%~dp0\bin\gdal\csharp;%~dp0\bin\ms\csharp;%~dp0\bin\curl;%PATH%
SET GDAL_DATA=%~dp0\bin\gdal-data
SET GDAL_DRIVER_PATH=%~dp0\bin\gdal\plugins
SET PYTHONPATH=%~dp0\bin\gdal\python\osgeo;%~dp0\bin\ms\python
SET PROJ_LIB=%~dp0\bin\proj\SHARE
:exit
Unfortunately I am a greenhorn when it comes to cmd commands and *.bat-files, so any help would be appreciated. Another option would be to rewrite the *bat in a way that all changes listed there are permanently. I have tried to do so (with setx, etc), but obviously I miss something.
regards,
Ludwig