7.2 Interactive Mode

If insufficient number of arguments is given in the command line, smapc enters interactive mode. In this mode it reads commands from the standard input, executes them and displays the results on the standard output. If the standard input is connected to a terminal, the readline and history facilities are enabled (see (readline)Command Line Editing section `Command Line Editing' in GNU Readline Library).

When in interactive mode, smapc displays its prompt and waits for you to enter a command. The default prompt is the name of the program, enclosed in parentheses:

(smapc) _

Depending on the first character, your input is recognized either as a smapc command, or as a query. All smapc commands begin with a single punctuation character, called command prefix. The default command prefix is a dot, but it can be changed using the prefix command (see section prefix). The prefix is not a part of the command, it is merely a means by which smapc recognizes that it has been given a command. So, when explaining commands below, we will refer to them by their name, without the prefix.

The most important command is ‘open’. It takes a server URL as its argument and opens a connection to that server:

(smapc) .open unix:///var/run/smap/sockmap

Now, if you type two or more words (the first of them not starting with the command prefix), smapc builds a query using the first word as of them is used as a map name and the rest of them as a key. It then sends the request to the server using the socket opened with the open command and displays the result on the standard output:

(smapc) aliases root@domain.com
OK smith dmk <rev@another.domain>

If you wish to change to another URL, give another ‘open’ command. Do not bother to close the previously opened socket: it will be done automatically.

If you are going to send a series of queries using the same map, you will save yourself some typing by declaring the default map, e.g.:

(smapc) .map aliases

From now on, every non-command input you give will be treated as lookup keys for that map name, e.g.:

(smapc) root@domain.com
OK smith dmk <rev@another.domain>
(smapc) postmaster
OK root
(smapc) daemon

If you forget what map you are currently using, type the map command without arguments. It will display the map name:

(smapc) .map
current map is aliases

Finally, to forget the default map and return to typing map name before the key, use ‘nomap’:

(smapc) .nomap

To quit the program, type ‘.quit’. Typing end-of-file character (C-d) has the same effect.

To obtain a listing of available commands with a short description for each of them, type ‘help’ or ‘?’.

7.2.1 Smapc Command Summary

This subsection lists all available smapc commands along with their short description and a reference to the part of this manual where they are described in detail. The command names are given without prefix.

smapc: open url

Open connection to socket map server at the given url. See smapc-open.

smapc: close

Close previously opened connection.

smapc: server

Show URL of the currently opened connection.

smapc: help

Display short command usage summary.

smapc: map [name]

Set the default map name. Without arguments, print the name of the map currently in use. See smapc-defmap.

smapc: nomap

Clear the default map name. After this command, map names must be given explicitly with each query. See nomap.

smapc: source [ip]

With argument, sets the source address for outgoing queries. Without argument, displays currently used source address.

smapc: debug spec

Sets the debug level. See section Tracing and Debugging, for a description of spec.

smapc: prefix [char]

If char is given, sets it as the command prefix. If called without arguments, displays the currently selected command prefix.

smapc: prompt [string]

Redefines the command prompt. Without arguments, prints the current prompt.

smapc: history

Prints the history of recently issued commands.

smapc: quit

Quits interactive mode.

smapc: quiet bool

This command command toggles the display of smapc startup banner. When started, smapc prints a short list of information useful for beginning users: the program version and warranty conditions and a command to get help, e.g.:

smapc (smap) 1.1
Copyright (C) 2010 Sergey Poznyakoff
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Type ? for help summary

(smapc) _

If you find this output superfluous and useless, you can suppress it by setting

quiet yes

in your initialization file.

smapc: version

Displays the package name and version number.

smapc: warranty

Displays the copyright statement.