I am trying to run shell scripts with Orfeo-toolbox commands, and I'm new to all this…. (I'm working in Windows 7).
I can type
otbcli_ComputeImagesStatistics -il Imagery/P1_10cm1.tif Imagery/P2_10c1.tif -out ImageAnalysis/Stats12_JUNK3.xml
directly into the OSGeo4W shell window and things work fine. Now I'd like to put more commands in a script and run them all at once.
I'm following the advice from this question.
If I save that text in a file called TryShell.sh
and enter in shell window:
sh TryShell.sh
I get the error TryShell.sh: line 1: otbcli_ComputeImagesStatistics: command not found
Why does the otbcli
command work in the shell but not in the shell script?
Best Answer
Working in person with a friend, I think I figured it out. It turns out you can save the commands in a
.bat
file and just type that file into the prompt in the OSGeo4W shell. This works without setting any path.** The catch, is that it seems that commands like
otbcli_ComputeImagesStatistics
are themselves batch calls, so if I put more than one of them in the same .bat file it would only execute the first one. The problem was solved by putting "call" on the line in front of theotbcli_*
commands.So to sum up, make a file
TEST.bat
, with commands like:and then type
Test.bat
at the prompt in the OSGeo4W shell. This was tested on Windows 7 and 8.