<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FPmolzer</id>
	<title>GRASS-Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FPmolzer"/>
	<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/wiki/Special:Contributions/%E2%9A%A0%EF%B8%8FPmolzer"/>
	<updated>2026-05-25T22:17:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_Shell&amp;diff=25425</id>
		<title>GRASS and Shell</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_Shell&amp;diff=25425"/>
		<updated>2018-12-20T00:39:40Z</updated>

		<summary type="html">&lt;p&gt;⚠️Pmolzer: /* See also */ add link to windows console page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about GRASS GIS' own shell setup and use. &lt;br /&gt;
&lt;br /&gt;
For information about scripting for GRASS, please refer to the page [http://grasswiki.osgeo.org/wiki/Shell_scripting Shell scripting].&lt;br /&gt;
&lt;br /&gt;
== Automated batch jobs: Setting the GRASS environmental variables ==&lt;br /&gt;
&lt;br /&gt;
'''''Main article: [[Working with GRASS without starting it explicitly]]'''''&lt;br /&gt;
&lt;br /&gt;
This section applies to jobs which shall set the entire GRASS environment.&lt;br /&gt;
You have to set a couple of variables to enable GRASS command to run from outside GRASS:&lt;br /&gt;
&lt;br /&gt;
   # Example in bash shell syntax:&lt;br /&gt;
 &lt;br /&gt;
   # path to GRASS binaries and libraries:&lt;br /&gt;
   export GISBASE=/usr/lib64/grass74&lt;br /&gt;
 &lt;br /&gt;
   export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts&lt;br /&gt;
   export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GISBASE/lib&lt;br /&gt;
   &lt;br /&gt;
   # set PYTHONPATH to include the GRASS Python lib&lt;br /&gt;
   if [ ! &amp;quot;$PYTHONPATH&amp;quot; ] ; then&lt;br /&gt;
      PYTHONPATH=&amp;quot;$GISBASE/etc/python&amp;quot;&lt;br /&gt;
   else&lt;br /&gt;
      PYTHONPATH=&amp;quot;$GISBASE/etc/python:$PYTHONPATH&amp;quot;&lt;br /&gt;
   fi&lt;br /&gt;
   export PYTHONPATH&lt;br /&gt;
 &lt;br /&gt;
   # use process ID (PID) as lock file number:&lt;br /&gt;
   export GIS_LOCK=$$&lt;br /&gt;
 &lt;br /&gt;
   # settings for graphical output to PNG file (optional)&lt;br /&gt;
   export GRASS_PNGFILE=/tmp/grass6output.png&lt;br /&gt;
   export GRASS_TRUECOLOR=TRUE&lt;br /&gt;
   export GRASS_WIDTH=900&lt;br /&gt;
   export GRASS_HEIGHT=1200&lt;br /&gt;
   export GRASS_PNG_COMPRESSION=1&lt;br /&gt;
   export GRASS_MESSAGE_FORMAT=plain&lt;br /&gt;
&lt;br /&gt;
Define a GRASS session with the last used GISDBASE, LOCATION_NAME, and MAPSET&lt;br /&gt;
&lt;br /&gt;
   # path to GRASS settings file&lt;br /&gt;
   export GISRC=$HOME/.grassrc7&lt;br /&gt;
&lt;br /&gt;
Define a GRASS session with a different GISDBASE, LOCATION_NAME, and/or MAPSET&lt;br /&gt;
&lt;br /&gt;
   # path to GRASS settings file&lt;br /&gt;
   export GISRC=/tmp/grass7-${USER}-$GIS_LOCK/gisrc&lt;br /&gt;
   # remove any leftover files/folder&lt;br /&gt;
   rm -fr /tmp/grass7-${USER}-$GIS_LOCK&lt;br /&gt;
   mkdir /tmp/grass7-${USER}-$GIS_LOCK&lt;br /&gt;
   export TMPDIR=&amp;quot;/tmp/grass7-${USER}-$GIS_LOCK&amp;quot;&lt;br /&gt;
   # set GISDBASE, LOCATION_NAME, and/or MAPSET&lt;br /&gt;
   echo &amp;quot;GISDBASE: /path/to/some/grassdata&amp;quot; &amp;gt;&amp;gt;$GISRC&lt;br /&gt;
   echo &amp;quot;LOCATION_NAME: some_location&amp;quot; &amp;gt;&amp;gt;$GISRC&lt;br /&gt;
   echo &amp;quot;MAPSET: some_mapset&amp;quot; &amp;gt;&amp;gt;$GISRC&lt;br /&gt;
   # start in text mode&lt;br /&gt;
   echo &amp;quot;GRASS_GUI: text&amp;quot; &amp;gt;&amp;gt;$GISRC&lt;br /&gt;
&lt;br /&gt;
The following three settings are only recommended if you will be calling the script from another program - e.g. a PHP web page using system() or exec()&lt;br /&gt;
&lt;br /&gt;
   export HOME=/var/www&lt;br /&gt;
   export USER=www-data&lt;br /&gt;
   export GROUP=www-data&lt;br /&gt;
&lt;br /&gt;
Now you can test:&lt;br /&gt;
&lt;br /&gt;
   # this should print the GRASS version used:&lt;br /&gt;
   g.version&lt;br /&gt;
   # check GISDBASE, LOCATION_NAME, and MAPSET&lt;br /&gt;
   g.gisenv&lt;br /&gt;
   # other calculations go here ...&lt;br /&gt;
&lt;br /&gt;
If this works, you can launch other GRASS commands. The approach works within Shell scripts and also in the command line terminal.&lt;br /&gt;
&lt;br /&gt;
When done, you should cleanup internal tmp files like this:&lt;br /&gt;
&lt;br /&gt;
   # run GRASS' cleanup routine&lt;br /&gt;
   $GISBASE/etc/clean_temp&lt;br /&gt;
 &lt;br /&gt;
   # remove session tmp directory:&lt;br /&gt;
   rm -rf /tmp/grass7-${USER}-$GIS_LOCK&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Changing the prompt:'''&lt;br /&gt;
&lt;br /&gt;
   PS1_BACKUP=&amp;quot;$PS1&amp;quot;&lt;br /&gt;
   export PS1=&amp;quot;GRASS 6&amp;gt; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Once you are done, you can set it back (see also next hint about unsetting variables):&lt;br /&gt;
   export PS1=&amp;quot;$PS1_BACKUP&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''Unsetting variables after usage:'''&lt;br /&gt;
&lt;br /&gt;
   Using the &amp;quot;unset VARNAME&amp;quot; command you get rid of it:&lt;br /&gt;
   unset GISBASE&lt;br /&gt;
   unset GISRC&lt;br /&gt;
   ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
* GRASS shell script job to generate a [http://grass.fbk.eu/spearfish/php_grass_earthquakes.php Recent Earthquakes Map] (get the [http://grass.fbk.eu/spearfish/grass_earthquakes.sh grass_earthquakes.sh shell script])&lt;br /&gt;
&lt;br /&gt;
=== Parallel GRASS jobs ===&lt;br /&gt;
&lt;br /&gt;
See [[Parallel GRASS jobs]] for Grid Engine, PBS etc.&lt;br /&gt;
&lt;br /&gt;
=== GRASS Batch jobs ===&lt;br /&gt;
&lt;br /&gt;
Since GRASS GIS 6.4, there is an alternative method to easily run jobs in GRASS from a collection of commands in a shell script file. Just define the environmental variable GRASS_BATCH_JOB with the shell script file containing GRASS (or whatever) commands, preferably with full path. Then launch GRASS and it will be executed. It is best to launch GRASS in &amp;lt;tt&amp;gt;-text&amp;lt;/tt&amp;gt; mode and to provide gisdbase/location/mapset as parameters. The job script needs executable file permissions (&amp;lt;tt&amp;gt;chmod&amp;lt;/tt&amp;gt; on Unix). In order to get readable percentage output during the processing (0..2..4... 100%), we set the environment variable GRASS_MESSAGE_FORMAT to &amp;quot;plain&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#### 1) PREPARATION&lt;br /&gt;
# First we generate a script which contains the command(s) to be executed:&lt;br /&gt;
# for convenience, we save the file in our HOME directory&lt;br /&gt;
## You may use also a text editor for this, here we use the &amp;quot;echo&amp;quot; shell command&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;export GRASS_MESSAGE_FORMAT=plain&lt;br /&gt;
# set computational region, here: UTM32N coordinates&lt;br /&gt;
g.region n=4900000 s=4800000 w=700000 e=800000 res=100&lt;br /&gt;
v.random mymap3000 n=3000&lt;br /&gt;
v.out.ogr input=mymap3000 output=mymap3000.shp&amp;quot; &amp;gt; $HOME/my_grassjob.sh&lt;br /&gt;
&lt;br /&gt;
# verify the content of the file&lt;br /&gt;
cat $HOME/my_grassjob.sh&lt;br /&gt;
&lt;br /&gt;
# make it user executable (this is important, use 'chmod' or via file manager)&lt;br /&gt;
chmod u+x $HOME/my_grassjob.sh&lt;br /&gt;
&lt;br /&gt;
# create a directory (may be elsewhere) to hold the location used for processing&lt;br /&gt;
mkdir -p $HOME/grassdata&lt;br /&gt;
&lt;br /&gt;
# create new temporary location for the job, exit after creation of this location&lt;br /&gt;
grass70 -c epsg:32632 $HOME/grassdata/mytemploc_utm32n -e&lt;br /&gt;
&lt;br /&gt;
#### 2) USING THE BATCH JOB&lt;br /&gt;
# define job file as environmental variable&lt;br /&gt;
export GRASS_BATCH_JOB=&amp;quot;$HOME/my_grassjob.sh&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# now we can use this new location and run the job defined via GRASS_BATCH_JOB&lt;br /&gt;
grass70 $HOME/grassdata/mytemploc_utm32n/PERMANENT&lt;br /&gt;
&lt;br /&gt;
#### 3) CLEANUP&lt;br /&gt;
# switch back to interactive mode, for the next GRASS GIS session&lt;br /&gt;
unset GRASS_BATCH_JOB&lt;br /&gt;
&lt;br /&gt;
# delete temporary location (consider to export results first in your batch job)&lt;br /&gt;
rm -rf $HOME/grassdata/mytemploc_utm32n&lt;br /&gt;
&lt;br /&gt;
# Now you can use the resulting SHAPE file &amp;quot;mymap3000.shp&amp;quot; elsewhere.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The grass70 command starts GRASS in the given mapset, executes the contents of the job file and leaves GRASS. Since the normal startup/closure is used, all internal tmp files are properly removed.&lt;br /&gt;
&lt;br /&gt;
Note: The $HOME variable (or the ~ shortcut) cannot be used in the batch job itself since the variables are not available here.&lt;br /&gt;
&lt;br /&gt;
==== Example ====&lt;br /&gt;
&lt;br /&gt;
* Another set of GRASS shell scripts to run the job to generate another version of the [http://adhoc.osgeo.osuosl.org/grass/alternate_projections/earthquakes_wintri.png Recent Earthquakes Map] (find the setup files in the [https://trac.osgeo.org/grass/browser/grass-promo/tutorials/batch_processing &amp;quot;batch_processing&amp;quot; tutorials section] of the GRASS SVN)&lt;br /&gt;
&lt;br /&gt;
=== Unattended execution ===&lt;br /&gt;
&lt;br /&gt;
* {{wikipedia|GNU_Screen}} is another ''extremely'' valuable tool if you need to detatch and leave long-running processes unattended. It is well worth your time to learn how to use it if you run scripts on remote systems. There are many good tutorials on the web.&lt;br /&gt;
: Usage:&lt;br /&gt;
:: Run &amp;quot;screen&amp;quot; in the terminal. You will reach again the command line but now in screen mode. Now start GRASS. &lt;br /&gt;
::: - To disconnect from the session press Control-A, Control-D.&lt;br /&gt;
::: - To list your screens type &amp;quot;screen -ls&amp;quot; (to find it back)&lt;br /&gt;
::: - To reconnect with a disconnected screen run &amp;quot;screen -r [identifier]&amp;quot; (the &amp;quot;identifier&amp;quot; you need only if you have several screens running)&lt;br /&gt;
:: Enjoy.&lt;br /&gt;
&lt;br /&gt;
* Along with the &amp;quot;{{wikipedia|nohup}}&amp;quot; (no hang-up) command you can login to your machine, launch the job and leave the machine again. &lt;br /&gt;
The process will continue after you logged off when you start it with nohup:&lt;br /&gt;
        nohup grass64 ~/grassdata/spearfish60/neteler/ &amp;amp;&lt;br /&gt;
&lt;br /&gt;
=== Receive a notification when finished ===&lt;br /&gt;
&lt;br /&gt;
Maybe put email notification at the end of 'my_grassjob.sh' using the &amp;quot;mail&amp;quot; or the &amp;quot;mutt&amp;quot; program, for example like this:&lt;br /&gt;
&lt;br /&gt;
        echo &amp;quot;Finished at `date`&amp;quot; &amp;gt; /tmp/done.txt &amp;amp;&amp;amp; \&lt;br /&gt;
        EDITOR=touch mutt -s &amp;quot;Job done&amp;quot; \&lt;br /&gt;
        me@mydomain.org &amp;lt; /tmp/done.txt &amp;amp;&amp;amp; rm -f /tmp/done.txt&lt;br /&gt;
&lt;br /&gt;
or like this:&lt;br /&gt;
        mail -s &amp;quot;GRASS job $0 finished&amp;quot; me@mydomain.org &amp;lt;&amp;lt;EOF&lt;br /&gt;
          GRASS GIS has finished the batch job $0&lt;br /&gt;
        EOF&lt;br /&gt;
&lt;br /&gt;
or simply like this:&lt;br /&gt;
        echo &amp;quot;GRASS GIS has finished the batch job $0&amp;quot; | mail -s &amp;quot;GRASS job finished&amp;quot; me@mydomain.org&lt;br /&gt;
&lt;br /&gt;
== Stupid pet tricks (don't use them!) ==&lt;br /&gt;
&lt;br /&gt;
Note: This is highly discouraged. Keep fingers off from manually modifying the content of a GRASS GIS mapset (at least don't complain if you break things).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strike&amp;gt;;Quick cd to the MAPSET directory&lt;br /&gt;
To make a quick little function called 'g.cd' to change into the mapset dir, add this to &amp;lt;tt&amp;gt;~/.grass.bashrc&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.cd()&lt;br /&gt;
{&lt;br /&gt;
  MAPSET=`g.gisenv get=MAPSET`&lt;br /&gt;
  LOCATION_NAME=`g.gisenv get=LOCATION_NAME`&lt;br /&gt;
  GISDBASE=`g.gisenv get=GISDBASE`&lt;br /&gt;
  LOCATION=&amp;quot;$GISDBASE/$LOCATION_NAME/$MAPSET&amp;quot;&lt;br /&gt;
  cd &amp;quot;$LOCATION/$1&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With that you can also do like: &amp;quot;&amp;lt;tt&amp;gt;g.cd colr/&amp;lt;/tt&amp;gt;&amp;quot; to get to the color tables directory, or &amp;quot;&amp;lt;tt&amp;gt;g.cd ..&amp;lt;/tt&amp;gt;&amp;quot; to get to the LOCATION directory.&lt;br /&gt;
&lt;br /&gt;
Another method would be&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
  alias g.home='cd `dirname &amp;quot;$HISTFILE&amp;quot;`'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/strike&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Simpler command completion from command history&lt;br /&gt;
&lt;br /&gt;
Add this to a file called &amp;lt;tt&amp;gt;~/.inputrc&amp;lt;/tt&amp;gt; in your home dir:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
set prefer-visible-bell&lt;br /&gt;
&lt;br /&gt;
# -------- Bind page up/down wih history search ---------&lt;br /&gt;
&amp;quot;\e[5~&amp;quot;: history-search-backward&lt;br /&gt;
&amp;quot;\e[6~&amp;quot;: history-search-forward&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you can type a bit of a command and use PgUp and PgDn to cycle through the command history which matches in a way less clumsy that Ctrl-r. Also it tells to make the shell flash on alarm instead of sending a beep to the speaker (making tab-completion compatible with your office mates).&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
Generic Shell script tutorials:&lt;br /&gt;
* [http://tldp.org/LDP/abs/abs-guide.pdf Advance bash-scripting guide]&lt;br /&gt;
* [http://www.linuxconfig.org/Bash_scripting_Tutorial Bash scripting Tutorial]&lt;br /&gt;
&lt;br /&gt;
GRASS Shell script tutorials:&lt;br /&gt;
* [http://www.grassbook.org/examples_menu3rd.php GRASS Book script examples]&lt;br /&gt;
* [http://www.grassbook.org/unix_commands_table.php List of important UNIX system commands]&lt;br /&gt;
&lt;br /&gt;
Misc:&lt;br /&gt;
* [[Script portability]]&lt;br /&gt;
* Other GRASS environment {{cmd|variables}}&lt;br /&gt;
* [[GRASS and Python]]&lt;br /&gt;
* [[Working with GRASS without starting it explicitly]]&lt;br /&gt;
* [[GRASS and windows console]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Scripting]]&lt;br /&gt;
[[Category:Linking to other languages]]&lt;/div&gt;</summary>
		<author><name>⚠️Pmolzer</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_windows_console&amp;diff=25424</id>
		<title>GRASS and windows console</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_windows_console&amp;diff=25424"/>
		<updated>2018-12-20T00:35:03Z</updated>

		<summary type="html">&lt;p&gt;⚠️Pmolzer: remove useless info from the selecting a shell section.  note - this section not valid until next release&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This page shows extended examples how to run GRASS modules in the winGRASS windows console''&lt;br /&gt;
&lt;br /&gt;
==Windows batch files in GRASS==&lt;br /&gt;
&lt;br /&gt;
In order to ease the workflow of analysis, several GRASS modules can be invoked at once by an batch file (*.bat) in the winGRASS windows console.&lt;br /&gt;
&lt;br /&gt;
[https://trac.osgeo.org/grass/browser/grass/trunk/scripts Python grass modules] (e.g. v.db.addcolumn) have to be invoked by ''call'' in the batch-file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
@ECHO ON&lt;br /&gt;
g.region -p&lt;br /&gt;
v.in.region output=myreg&lt;br /&gt;
call v.db.addtable map=myreg&lt;br /&gt;
call v.db.addcolumn map=myreg columns=&amp;quot;col1 double&amp;quot;&lt;br /&gt;
v.to.db map=myreg option=area columns=col1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running batch files without starting up GRASS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;%ProgramFiles?%\QGIS 2.18\bin\Grass72.bat&amp;quot; --exec MyScript.bat D:/myGrassData/MyLoc/MyMapset &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==g.list output as input for another GRASS module==&lt;br /&gt;
&lt;br /&gt;
Using g.list output as input variable for another module, e.g. to remove a list raster map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
FOR /F %c in ('g.list &amp;quot;type=raster&amp;quot; &amp;quot;pattern=*2&amp;quot; &amp;quot;mapset=user1&amp;quot; &amp;quot;separator=comma&amp;quot;') DO SET RASTER2REMOVE=%c&lt;br /&gt;
&lt;br /&gt;
echo %RASTER2REMOVE%&lt;br /&gt;
b172,d172,it172,r172&lt;br /&gt;
&lt;br /&gt;
g.remove type=raster name=%RASTER2REMOVE%&lt;br /&gt;
The following data base element files would be deleted:&lt;br /&gt;
raster/b172@user1&lt;br /&gt;
raster/d172@user1&lt;br /&gt;
raster/it172@user1&lt;br /&gt;
raster/r172@user1&lt;br /&gt;
WARNING: Nothing removed. You must use the force flag (-f) to actually&lt;br /&gt;
         remove them. Exiting. &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using g.list output as input variable for another module, e.g. to loop through a list of vector maps and buffer them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
FOR /F %c IN ('g.list &amp;quot;type=vector&amp;quot; &amp;quot;separator=comma&amp;quot;') DO SET VECTLIST=%c&lt;br /&gt;
&lt;br /&gt;
FOR %g IN (%VECTLIST%) DO v.buffer input=%g output=%g_buffer_200 distance=200&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== selecting a shell ==&lt;br /&gt;
On windows, in the absence of the environmental variable GRASS_SH, the grass startup script selects the shell specified in environment variable ComSpec.  This is typically cmd.sh.&lt;br /&gt;
The default shell can be overridden by setting the environment variable GRASS_SH. To make powershell the startup command shell set the environment variable with&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
GRASS_SH=%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: Development]]&lt;br /&gt;
[[Category: FAQ]]&lt;br /&gt;
[[Category: WinGRASS]]&lt;/div&gt;</summary>
		<author><name>⚠️Pmolzer</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_windows_console&amp;diff=25423</id>
		<title>GRASS and windows console</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_windows_console&amp;diff=25423"/>
		<updated>2018-12-20T00:07:21Z</updated>

		<summary type="html">&lt;p&gt;⚠️Pmolzer: added the selecting a shell section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;''This page shows extended examples how to run GRASS modules in the winGRASS windows console''&lt;br /&gt;
&lt;br /&gt;
==Windows batch files in GRASS==&lt;br /&gt;
&lt;br /&gt;
In order to ease the workflow of analysis, several GRASS modules can be invoked at once by an batch file (*.bat) in the winGRASS windows console.&lt;br /&gt;
&lt;br /&gt;
[https://trac.osgeo.org/grass/browser/grass/trunk/scripts Python grass modules] (e.g. v.db.addcolumn) have to be invoked by ''call'' in the batch-file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
@ECHO ON&lt;br /&gt;
g.region -p&lt;br /&gt;
v.in.region output=myreg&lt;br /&gt;
call v.db.addtable map=myreg&lt;br /&gt;
call v.db.addcolumn map=myreg columns=&amp;quot;col1 double&amp;quot;&lt;br /&gt;
v.to.db map=myreg option=area columns=col1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running batch files without starting up GRASS:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;%ProgramFiles?%\QGIS 2.18\bin\Grass72.bat&amp;quot; --exec MyScript.bat D:/myGrassData/MyLoc/MyMapset &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==g.list output as input for another GRASS module==&lt;br /&gt;
&lt;br /&gt;
Using g.list output as input variable for another module, e.g. to remove a list raster map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
FOR /F %c in ('g.list &amp;quot;type=raster&amp;quot; &amp;quot;pattern=*2&amp;quot; &amp;quot;mapset=user1&amp;quot; &amp;quot;separator=comma&amp;quot;') DO SET RASTER2REMOVE=%c&lt;br /&gt;
&lt;br /&gt;
echo %RASTER2REMOVE%&lt;br /&gt;
b172,d172,it172,r172&lt;br /&gt;
&lt;br /&gt;
g.remove type=raster name=%RASTER2REMOVE%&lt;br /&gt;
The following data base element files would be deleted:&lt;br /&gt;
raster/b172@user1&lt;br /&gt;
raster/d172@user1&lt;br /&gt;
raster/it172@user1&lt;br /&gt;
raster/r172@user1&lt;br /&gt;
WARNING: Nothing removed. You must use the force flag (-f) to actually&lt;br /&gt;
         remove them. Exiting. &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using g.list output as input variable for another module, e.g. to loop through a list of vector maps and buffer them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
FOR /F %c IN ('g.list &amp;quot;type=vector&amp;quot; &amp;quot;separator=comma&amp;quot;') DO SET VECTLIST=%c&lt;br /&gt;
&lt;br /&gt;
FOR %g IN (%VECTLIST%) DO v.buffer input=%g output=%g_buffer_200 distance=200&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== selecting a shell ==&lt;br /&gt;
On windows, in the absence of the environmental variable GRASS_SH, the grass startup script selects the shell specified in environment variable ComSpec.  This is typically cmd.sh.&lt;br /&gt;
The default shell can be overridden by setting the environment variable GRASS_SH.  Several shells are supported in the grass.py wrapper script ( AKA grass74.py for a version 7.4 install).  These are ksh, csh, tcsh, bash, sh, zsh, cmd, and powershell. To make powershell the startup command shell set the environment variable with&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bat&amp;quot;&amp;gt;&lt;br /&gt;
GRASS_SH=%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category: Development]]&lt;br /&gt;
[[Category: FAQ]]&lt;br /&gt;
[[Category: WinGRASS]]&lt;/div&gt;</summary>
		<author><name>⚠️Pmolzer</name></author>
	</entry>
</feed>