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

9 The rushwho utility.

The rushwho utility displays a list of users who are currently using rush. The utility operates on default Rush database, which is maintained if rush runs in accounting mode (see Accounting and Forked Mode). The following is a sample output from rushwho:

Login      Rule     Start     Time       PID      Command
jeff       sftp     Sun 12:17 00:58:26   10673    bin/sftp-server

The information displayed is:

Login

The login name of the user.

Rule

The tag of the rule he is served under (see tag).

Start

Time when the rule began execution.

Time

Duration of the session.

PID

PID of the running command.

Command

Command line being executed.

This format is a built-in default. It may be changed either by setting the RUSHWHO_FORMAT environment variable to the desired format string, or by using --format command line option.

9.1 Rushwho Options

This section summarizes the command line options understood by rushwho utility.

-F string
--format=string

Use string instead of the default format, described in Rushwho. See Formats, for a detailed description of the output format syntax. If string begins with a ‘@’, then this character is removed from it, and the resulting string is regarded as a name of the file to read. The contents of this file is the format string. The file is read literally, except that lines beginning with ‘;’ are ignored (they can be used to introduce comments). For example, rushwho --format=@formfile reads in the contents of the file named formfile.

-f dir
--file=dir

Use database directory dir, instead of the default. By default, database files are located in /usr/local/var/rush.

-H
--no-header

Do not display header line.

-v
--version

Display program version.

-h
--help

Display a short help message.

--usage

Display a concise usage summary.

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 any 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. The rest of 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.

The 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 of a 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 exact data are 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 for the data. This keyword is ignored if width is not given.

The keyword :empty followed by a string causes 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 has sense 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 chapter):   Section:   Chapter:FastBack: Rushwho   Up: Rushwho   FastForward: Rushlast   Contents: Table of ContentsIndex: Concept Index