GNU Rush – a restricted user shell (split by node):   Section:   Chapter:FastBack: Rushwho   Up: Rushwho   FastForward: Rushlast   Contents: Table of ContentsIndex: Concept Index

9.2 Output Formats

A format string controls the output of every record from GNU Rush accounting database. It may contain following four types of objects:

Ordinary characters

These are copied to the output verbatim.

Escapes

An escape is a backslash (‘\\’), followed by a single character. It is interpreted as follows:

EscapeOutput
\aAudible bell character (ASCII 7)
\bBackspace character (ASCII 8)
\eEscape character (ASCII 27)
\fForm-feed character (ASCII 12)
\nNewline character (ASCII 10)
\rCarriage return character (ASCII 13)
\tHorizontal tabulation character (ASCII 9)
\vVertical tabulation character (ASCII 11)
\\A single backslash (‘\’)
\"A double-quote.

Any escape not listed in the table above results in its second character being output.

Quoted strings

Strings are delimited by single or double quotes. Within a string escape sequences are interpreted as described above.

Format specifications

A format specification is a kind of function, which outputs a particular piece of information from the database record.

Each format specification starts with an opening brace and ends with a closing brace. The first word after the brace is the name of the format specification. Remaining words are positional arguments followed by keyword arguments. Both are optional. When specified, keyword arguments must follow positional ones. A keyword argument begins with a colon. For example:

(time)

A single format specification.

(time 10)

The same format specification with the output width limited to 10 characters.

(time 10 Duration)

The ‘time’ format specification, with the output width limited to 10 characters and ‘Duration’ as a header title.

(time 10 "Session Duration" :right :format %H:%M)

The same with two keyword arguments: ‘:right’ and ‘:format’. The latter takes the string ‘%H:%M’ as its argument. Notice the use of quoted string to preserve the whitespace.

A full list of format specifications follows.

Format Spec: newline [count]

Causes the newline character to be output. If the optional count is supplied, that many newlines will be printed

Format Spec: tab [num]

Advance to the next tab stop in the output stream. If optional num is present, then skip num tab stops. Each tab stop is eight characters long.

The following specifications output particular fields from the database record. They all take two positional arguments: width and title.

The first argument, width sets the maximum output length for this specification. If the number of characters actually output is less than the width, they will be padded with whitespace either to the left or to the right, depending on the presence of the :right keyword argument. If the number of characters is greater than width, they will be truncated to fit. If width is not given, the field is output as is.

The second argument, title, gives the title of this column for the heading line. By default no title is output.

Every field specification accepts at least two keyword arguments. The keyword :right may be used to request alignment to the right. This keyword is ignored if width is not given.

The keyword :empty followed by a string instructs rushwho to output that string if the resulting value for this specification would otherwise be empty.

Format Spec: user width title [:empty repl][:right]

Print the user login name.

Format Spec: time width title [:empty repl] [:right] [:format date-format]
Format Spec: start-time width title [:empty repl] [:right] [:format date-format]

Date and time when the session started.

The :format keyword introduces the strftime format string to be used when converting the date for printing. The default value is ‘%a %H:%M’. See Time and Date Formats, for a detailed description of strftime format strings.

Format Spec: stop-time width title [:empty repl] [:right] [:format date-format]

Time when the command finished. This specifier is meaningful only for rushlast (see Rushlast). If the command is still running, the word ‘running’ is output.

Format Spec: duration width title [:empty repl] [:right]

Total time of the session duration.

Format Spec: rule width title [:right]

The tag of the rule used to serve the user. See tag, for a detailed description of rules and tags.

Format Spec: command width title [:empty repl] [:right]

Command line being executed.

Format Spec: pid width title [:right]

PID of the process.

For example, the following is the default format for the rushwho utility. It is written in a form suitable for use in a file supplied with the --format=@file command line option (see format option):

(user 10 Login)" "
(rule 8 Rule)" "
(start-time 0 Start)" "
(duration 9 Time)" "
(pid 10 PID)" "
(command 28 Command)

GNU Rush – a restricted user shell (split by node):   Section:   Chapter:FastBack: Rushwho   Up: Rushwho   FastForward: Rushlast   Contents: Table of ContentsIndex: Concept Index