GRASS logo

Note: A new GRASS GIS stable version has been released: GRASS GIS 7. Go directly to the new manual page here


g.message - Prints a message, warning, progress info, or fatal error in the GRASS way.
This module should be used in scripts for messages served to user.


general, scripts


g.message help
g.message [-wedpiv] message=string [debug=integer] [--verbose] [--quiet]


Print message as warning
Print message as fatal error
Print message as debug message
Print message as progress info
Print message in all but full quiet mode
Print message only in verbose mode
Verbose module output
Quiet module output


Text of the message to be printed
Level to use for debug messages
Options: 0-5
Default: 1


This program is to be used in shell/perl/python scripts, so the author does not need to use the echo program. The advantage of g.message is that it formats messages just like other GRASS modules do and that its functionality is influenced by the GRASS_VERBOSE and GRASS_MESSAGE_FORMAT environment variables.

The program can be used for standard informative messages as well as warnings (-w flag) and fatal errors (-e flag). For debugging purposes, the -d flag will cause g.message to print a debugging message at the given level.


Messages containing "=" must use the full message= syntax so the parser doesn't get confused.

If you want a long message (multi-line) to be dealt with as a single paragraph, use a single call to g.message with text split in the script using the backslash as the last character. (In shell scripts don't close the "quote")

A blank line may be obtained with: g.message ""

Redundant whitespace will be stripped away.

It's advisable to single quote the messages that are to be printed literally. It prevents a number of characters (most notably, space and the dollar sign '$') from being treated specifically by the Shell.

When it is necessary to include, for example, a variable's value as part of the message, the double quotes may be used, which do not deprive the dollar sign of its special variable-expansion powers.

While it is known that the interactive Bash instances may treat the exclamation mark '!' character specifically (making single quoting of it necessary), it shouldn't be the case for the non-interactive instances of Bash. None the less, to avoid context-based confusion later on you are enouraged to single-quote messages that do not require $VARIABLE expansion.


Controlled by the "GRASS_VERBOSE" environment variable. Typically this is set using the --quiet or --verbose command line options.


Controlled by the "DEBUG" GRASS gisenv variable. (set with g.gisenv)
Recommended levels:


GRASS variables and environment variables,
g.gisenv, g.parser


Jachym Cepicky

Last changed: $Date: 2011-11-08 03:29:50 -0800 (Tue, 08 Nov 2011) $

Main index - general index - Full index

© 2003-2016 GRASS Development Team