Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
g.message(1)		    GRASS GIS User's Manual		  g.message(1)

       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,	support, scripts

       g.message --help
       g.message [-wedpiv] message=string  [debug=integer]   [--help]  [--ver-
       bose]  [--quiet]	 [--ui]

	   Print message as warning

	   Print message as fatal error

	   Print message as debug message

	   Print message as progress info

	   Print message in all	modes except of	quiet mode
	   Message is printed on GRASS_VERBOSE>=1

	   Print message only in verbose mode
	   Message is printed only on GRASS_VERBOSE>=3

	   Print usage summary

	   Verbose module output

	   Quiet module	output

	   Force launching GUI dialog

       message=stringA [required]
	   Text	of the message to be printed
	   Message is printed on GRASS_VERBOSE>=2

	   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_FOR-
       MAT 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 message=""

       Redundant whitespace will be stripped away.

       It's advisable to single	quote the messages that	are to be printed lit-
       erally.	 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 de-
       prive the dollar	sign of	its special variable-expansion powers.

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

   Usage in Python scripts
       GRASS Python Scripting Library defines special wrappers for g.message.

	   o   debug() for g.message -d

	   o   error() for g.message -e

	   o   fatal() for g.message -e	+ exit()

	   o   info() for g.message -i

	   o   message() for g.message

	   o   verbose() for g.message -v

	   o   warning() for g.message -w

       Note:  The Python tab in	the wxGUI can be used for entering the follow-
       ing sample code:

       import grass.script as gcore
       gcore.warning("This is a	warning")
       is identical with
       g.message -w message="This is a warning"

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

	   o   0 - only	errors and warnings are	printed

	   o   1 - progress messages are printed

	   o   2 - all module messages are printed

	   o   3 - additional verbose messages are printed

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

	   o   1 - message is printed once or few times	per module

	   o   3 - each	row (raster) or	line (vector)

	   o   5 - each	cell (raster) or point (vector)

       This basic example prints the message "hello" in	the console:
       g.message message="hello"

       To print	a message as an	error message use the -e flag:
       g.message -e message="my	error"

       To  print  a  message highlighted as a debug message ("D0/0: debug") in
       the console, use	the -d flag. Optionally	the debug level	can be defined
       (see also g.gisenv for details):
       # Levels: (recommended levels)
       #   0 - silence
       #   1 - message is printed once or few times per	module
       #   3 - each row	(raster) or line (vector)
       #   5 - each cell (raster) or point (vector)
       g.message -d message="debug" debug=0

       To print	a message highlighted as a warning message ("WARNING: my warn-
       ing") in	the console, use the -w	flag:
       g.message -w message="my	warning"

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

       Jachym Cepicky

       Available at: g.message source code (history)

       Main index | General index | Topics index | Keywords index |  Graphical
       index | Full index

       A(C) 2003-2020 GRASS Development	Team, GRASS GIS	7.8.3 Reference	Manual

GRASS 7.8.3							  g.message(1)


Want to link to this manual page? Use this URL:

home | help