My computer\'s OS is win7
I want to use a .bat file to open a new shell, then run script in a new shell
this shell is OSGeo4W Shell
it is located in
This is a good question. I'm also trying to do this. You can try putting the rest of the script in another .bat file or in a .sh file and pass this file as an argument to OSGeo4W.bat. The script would be something like this:
cd "C:\Program Files\QGIS Dufour\"
OSGeo4W.bat script_inside_the_shell.bat
or
cd "C:\Program Files\QGIS Dufour\"
OSGeo4W.bat sh script_inside_the_shell.sh
You could try this:
start cmd /K echo Hello world!
It definately works on windows XP, the /K runs the specified command but retains the new cmd prompt! Hope it is useful!
You could try this if you don't want the cmd prompt to remain:
start cmd /C echo Hello world!
i had similar problem, and i managed to resolved like this: I had a script file called script.bat with various python and ogr functions. In separate bat file i typed:
call "C:\Program Files\QGIS 2.14\OSGeo4w.bat" start cmd.exe /k script
pause
This bat file calls inital script.bat in OSGeo4W Shell.
*note1: Both bat files must be in same directory. **note2: In your case script.bat will have content:
ogr2ogr -f CSV my_csv Grid.dbf
ogr2ogr -f CSV csv Grid.dbf
addcenter.exe
ogr2ogr -f "ESRI Shapefile" my_dir ./csv/Grid.csv
copy Grid.shp my_dir
copy Grid.shx my_dir
rd my_csv /s /q
rd csv /s /q
ogr2ogr -clipsrc t.shp test.shp ./my_dir/Grid.shp
rd my_dir /s /q
ogr2ogr -f CSV wellcsv welllocation.dbf
ogr2ogr -f CSV csv test.dbf
computingArea.exe
ogr2ogr -f "ESRI Shapefile" my_dir ./csv/test.csv
rd csv /s /q
rd wellcsv /s /q
move test.shp my_dir
move test.shx my_dir
del test.dbf /q
and separate bat file will be:
call "C:\Program Files\QGIS Dufour\OSGeo4w.bat" start cmd.exe /k script
and both bat files must be in directory with data (C:\Users\tony\Downloads\11\computingArea). I hope this will work, it worked for me!
I am afraid I haven't used OSGeo4W I just assumed it was using windows. Regardless I'll list some options which work on Linux depending on the shell followed by an example using Cygwin. Maybe it will help..
-> You can use gnome-terminal Gnome-terminal is a terminal emulation application and the -x specifies you want execute the subsequent command:
gnome-terminal -x ./script.sh
-> Background Process in the current terminal You can background the first processes by adding an ampersand (&) to the command line or pressing Ctrl+Z when it is running. You then enter "bg" to let the process continue.
-> You can use xterm and background the process:
xterm -e ./myProcess3 &
-> An example using cygwin
cygstart /bin/bash -li
Hope I got all that right, I actually can't test it right now (new windows build PC).