GNU Rush |
|
Restricted User Shell |
Sergey Poznyakoff |
A format string controls the output of every record from GNU Rush accounting database. It may contain following four types of objects:
These are copied to the output verbatim.
An escape is a backslash (‘\\’), followed by a single character. It is interpreted as follows:
Escape | Output |
\a | Audible bell character (ASCII 7) |
\b | Backspace character (ASCII 8) |
\e | Escape character (ASCII 27) |
\f | Form-feed character (ASCII 12) |
\n | Newline character (ASCII 10) |
\r | Carriage return character (ASCII 13) |
\t | Horizontal tabulation character (ASCII 9) |
\v | Vertical 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.
Strings are delimited by single or double quotes. Within a string escape sequences are interpreted as described above.
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.
Causes the newline character to be output. If the optional count is supplied, that many newlines will be printed
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.
Print the user login name.
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.
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.
Total time of the session duration.
The tag of the rule used to serve the user. See tag, for a detailed description of rules and tags.
Command line being executed.
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)
This document was generated on January 2, 2022 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.