WARNING

This text was automatically converted from troff me macros to HTML. Information may have been lost, added, or changed in the process. Lars Aronsson and Lysator do not guarantee the correctness of this HTML document.

NAME

monitor *- run the interactive terminal monitor

SYNOPSIS

monitor [-h hostname] [-p port] [-t tty_device] [-N] [-T]
 [-c query] [-d path] [-q] [-o options] dbname

DESCRIPTION

The interactive terminal monitor is a simple frontend to POSTGRES. It enables one to formulate, edit and review queries before issuing them to POSTGRES. If changes must be made, a UNIX editor may be called called to edit the "query buffer" , which the terminal monitor manages. The editor used is determined by the value of the EDITOR environment variable. If EDITOR is not set, then vi is used by default.

The terminal monitor requires that the postmaster be running, and the ports (specified with the "-p" option or by the PGPORT environment variable) must be identical to those specified to the postmaster.

COMMAND OPTIONS

-h host specifies host machine on which the POSTGRES backend is running; default is your local machine (localhost).

-p port specifies the well known TCP/IP port used for network communication between the terminal monitor and the postmaster.

-t tty_device specifies the path name to the tty device (or regular UNIX file) which you want the backend debugging messages to be sent to; default is /dev/null. -N specifies that query results will be dumped to the screen without any attempt at formatting. This is useful in conjunction with the -c option in shell scripts.

-T specifies that attribute names will not be printed - only the data itself. This is useful in conjunction with the -c option in shell scripts.

-c query specifies that the monitor is to run one query and exit. This is useful for shell scripts, typically in conjunction with the -N and -T options. Examples of shell scripts in the POSTGRES distribution using monitor -c are createdb, destroydb, createuser, and destroyuser.

-d path specifies the path name of the file or tty which you want the frontend debugging messages to be written to; the default is not to generate any debugging messages.

-q specifies that the monitor should do its work quietly. By default, it prints welcome and exit messages and the queries it sends to the backend. If the -q flag is used, none of this happens.

-o options specifies additonal options for the POSTGRES backend. This is only intended for use by POSTGRES developers.

You may set environment variables to avoid typing the above options. See the ENVIRONMENT VARIABLES section below.

MESSAGES AND PROMPTS

The terminal monitor gives a variety of messages to keep the user informed of the status of the monitor and the query buffer.

When the terminal monitor is executed, it gives the current date and time, usually followed by the information in the dayfile (files).

The terminal monitor displays two kinds of messages: go The query buffer is empty and the terminal monitor is ready for input. Anything typed will be added to the buffer. * This prompt is typed at the beginning of each line when the terminal monitor is waiting for input.

TERMINAL MONITOR COMMANDS

&backslash; Enter the editor to edit the query buffer \g Submit query buffer to POSTGRES for execution \h Get on-line help \i filename Include the file filename into the query buffer \p Print contents of the query buffer \q Exit from the terminal monitor \r Reset (clear) the query buffer \s Escape to a UNIX subshell. To return to the terminal monitor, type exit at the shell prompt. \t Print current time \w filename Store the query buffer to an external file \\ Produce a single backslash at the current location in query buffer

ENVIRONMENT VARIABLES

You may set environment variables to avoid specifying command line options. These are as follows:

hostname: PGHOST
port:  PGPORT
tty:  PGTTY
options:  PGOPTION

If PGOPTION is specified, then the options it contains are parsed before any command-line options.

RETURN VALUE

When executed with the -c query option monitor returns 0 to the shell on successful query completion, 1 otherwise.

SEE ALSO

backend(unix), postmaster(unix), createdb(unix), destroydb(unix), createuser(unix), destroyuser(unix).