msg

Package: WA2L/edrc 1.5.57
Section: Library Commands (3)
Updated: 14 December 2007
Index Return to Main Contents

 

NAME

msg - write a message to screen

 

SYNOPSIS

edrc/lib/msg level "message text"

msg -h

 

AVAILABILITY

WA2L/edrc

 

DESCRIPTION

This command is used in scripts to write a standardized message to screen.

The message is printed to stderr and has the format:

<Scriptname>-<LEVEL>: <message text>

Example:

my_script-ERROR: directory '/dat/report/myreport' does not exist.

The <Scriptname> is derived from the $EDRC_SCRIPTNAME environment variable, the <LEVEL> is the upper case of the level string given as the first option of the command. The message text is printed as received from the other options of the command.

 

OPTIONS

level
Message level. The string given here is printed in upper case. There is no restriction in the level strings, a convention used in commands within WA2L/edrc is:
INFO
Information messages.

ERROR
An error occurred, that questions the correct output or function of the command. An error has to be corrected to ensure that the command can complete successfully.

WARNING
A non critical malfunction of the command occurred. Often a WARNING can be ignored, but in some occasions a warning can also lead to a minor reduction in output quality. A warning has to be analyzed and rated by the user.

FATAL
A fatal error is a condition that has to be analyzed and that needs user intervention and correction to ensure proper functionality.

message text
message to be printed.

 

ENVIRONMENT

$EDRC_SCRIPTNAME
scriptname that is printed in the <Scriptname> part of the output.

 

EXIT STATUS

0
no error.

4
usage listed.

 

EXAMPLES

The following examples are script cut-outs of Bourne-, Korn- or Bash shell scripts:

1) common usage

EDRC_SCRIPTNAME=`basename $0`; export EDRC_SCRIPTNAME

msg INFO "command started"

2) msg usage within a function with a return value

EDRC_SCRIPTNAME=`basename $0`; export EDRC_SCRIPTNAME

# is_bigger a b -- return True if a is bigger as b, else return False
#
is_bigger(){ a=$1; b=$2
        if [ $a -gt $b ]; then 
                msg INFO "'$a' is bigger as '$b'"
                echo True
        else
                msg INFO "'$a' is smaller or equal as '$b'"
                echo False
        fi
} # is_bigger

# main - main
#
main(){
        seconds=`date +%S`
        if [ `is_bigger $seconds 30` = True ]; then
                msg INFO "we are in the 2nd half of the current minute"
        else
                msg INFO "we are in the 1st half of the current minute"
        fi
} # main
main $*

 

SEE ALSO

edrcintro(1), log(3), sh(1), ksh(1)

 

NOTES

-

 

BUGS

-

 

AUTHOR

msg was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net . 

 

COPYRIGHT

Copyright © 2008 Christian Walther

This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
OPTIONS
ENVIRONMENT
EXIT STATUS
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 16:17:42 GMT, April 17, 2025