![]() |
Dico |
GNU Dictionary Server |
Sergey Poznyakoff |
7.2 Interactive Mode
If neither word nor URL nor any operation mode option were
given on the command line, dico
enters interactive mode. In
this mode it reads commands from the standard input, executes them and
displays results on the standard output. If the standard input is
connected to a terminal, the readline and history facilities are
enabled (see Command Line Editing in GNU Readline Library).
When in interactive mode, dico
displays its prompt and
waits for you to enter a command. The default prompt is the name
of the program, followed by a ‘greater than’ sign and a single
space:
dico> _
The input syntax is designed so as to save you the maximum amount of typing.
If you type any word, the default action is to look up its definition using the default server and database settings, for example:
dico> man From eng-swa, English-Swahili xFried/FreeDict Dictionary: man <n.> mwanamume
To match the word, instead of defining it, prefix it with a slash,
much as you do in vi
:
dico> /man From eng-swa, English-Swahili xFried/FreeDict Dictionary: 0) ``can'' 1) ``man'' 2) ``many'' 3) ``map'' 4) ``may'' 5) ``men''
Displayed is a list of matches retrieved using the default strategy. To see a definition for a particular match, type the number shown at its left. For example, to define “men”:
dico> 5 From eng-swa, English-Swahili xFried/FreeDict Dictionary: men <n.> wanaume
Define and match are two basic actions. To discern from them, the
rest of dico
commands begin with a command prefix, a
single punctuation character selected for this purpose. The default
command prefix is a dot, but it can be changed using the prefix
command (see prefix).
We will discuss the dico
commands in the following
subsections.
7.2.1 Server Commands
The open
command establishes connection to a remote
server. It takes up to two arguments, first of them specifying
the IP or host name of the server, and the optional second one
specifying the port number to connect to. For example:
dico> .open gnu.org.ua
If any or both of its arguments are absent, the open
command
reuses the value supplied with its previous invocation, or, if it is
issued for the first time, the default values. The default for server
name is ‘gnu.org.ua’ and the default port number is 2628. Both
values can be changed at configuration time, see Default Server
for a detailed instruction.
When given one argument, open
checks if it begins with a
directory separator (‘/’). If so, the argument is handled as the
full file name of a UNIX socket.
Note that you are not required to issue this command. If it is not
given, dico
will attempt to establish a connection using its
default settings before executing any command that requires a
connection to the server.
The close
command closes the connection. It does not take
any arguments.
7.2.2 Database and Strategy
The database
command changes or displays the database name which
is used by define and match commands. To display the database name,
type the command without arguments:
dico> .database !
To change the database, give its name as an argument to the command:
dico> .database *
Once the connection with the server is established, you may use command line completion facility to select the database from among those offered by the server. Typing TAB will show you a list of databases that begin with the characters you typed:
dico> .database enTAB en-pl-naut eng-afr eng-deu eng-swa
If you supply enough characters to identify a single choice, TAB will automatically select it. In the example above, typing a TAB after
dico> .database en-
completes the database name to:
dico> .database en-pl-naut
The strategy
command displays or changes the default strategy
name. As with database
, the strategy completion is available
for this command.
dico> .strategy . dico> .strategy dlev
If the remote server supports ‘xlev’ experimental capability
(see XLEV), you can use the distance
command
to set the maximum Levenshtein distance for strategies that use
Levenshtein algorithm. If used without arguments, this command
displays the distance reported by the server and the configured
distance, e.g.:
dico> .distance Reported Levenshtein distance: 1 No distance configured
If used with a single numeric argument, it attempts to set the distance to the supplied value.
7.2.3 Informational Commands
The ls
command lists available strategies (see SHOW
STRAT):
dico> .ls exact "Match words exactly" prefix "Match word prefixes" soundex "Match using SOUNDEX algorithm" all "Match everything (experimental)" lev "Match headwords within given Levenshtein distance" dlev "Match headwords within given Damerau-Levenshtein distance" re "POSIX 1003.2 (modern) regular expressions" regexp "Old (basic) regular expressions" suffix "Match word suffixes" rev-qu "Reverse search in Quechua databases"
The ld
command lists available databases (see SHOW
DB):
dico> .ld eng-swa "English-Swahili xFried/FreeDict Dictionary" swa-eng "Swahili-English xFried/FreeDict Dictionary" afr-eng "Afrikaans-English FreeDict Dictionary" eng-afr "English-Afrikaans FreeDict Dictionary"
The info
command displays information about a database, whose
name is given as its argument. If used without arguments, it displays
information about the current database.
dico> .info pl-en-naut pl-en-naut - A Polish-English dictionary of nautical terms. Copyright (C) 2008 Sergey Poznyakoff Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover and Back-Cover Texts.
7.2.4 History Commands
Each issued command is stored in a history list and assigned a
unique event number. When dico
exits, it saves the
command history to a file named .dico_history in your home
directory. Upon startup, it retrieves the history from this file, so
the history is preserved between sessions.
You can view the command history using the history
command:
dico> .history 1) .open dict.org 2) entdeckung 3) /geschwindigkeit
A number of editing commands is provided, that allow you to refer to
previous events from the history list and to edit them. For example,
to re-issue the 3rd event from the above list, type ‘!3’. The
command with this index will be inserted at the dico
prompt
and you will be given a possibility to edit it. For a detailed
description of all history-editing commands, please refer to
Using History Interactively in GNU History User Manual.
7.2.5 Pager
When a command produces output that contains more lines than
there are rows on the terminal, dico
attempts to use a
pager program to display it. The name (and arguments) of
the pager program are taken from the dico
internal variable,
or, if it is not set, from the PAGER
environment variable.
The dico
pager setting can be examined or changed using
the pager
command. When used without arguments, it displays
the current setting:
dico> .pager less (Pager set from environment)
When used with a single argument, it sets the pager:
dico> .pager "less -R"
The argument ‘-’ (a dash) disables pager.
7.2.6 Program Settings
The commands described in this subsection are designed mostly for
use in dico
initialization file (see Initialization File).
The autologin
command sets the name of autologin file to
be used for authentication. When used without arguments, it displays
the current setting. The argument to autologin
command is
subject to tilde expansion, i.e. if it begins with ‘~/’,
this prefix is replaced with the name of the current user home
directory, followed by ‘/’. Similarly, a prefix
‘~login/’ is replaced by the home directory for user
login, followed by a slash.
See Autologin, for a detailed discussion of the autologin feature.
The quiet
command toggles the display of dico
startup banner. When started, dico
prints a short list
of information useful for beginning users: the program version and
warranty conditions and a command to get help, e.g.:
dico 2.10 Copyright (C) 2005-2016 Sergey Poznyakoff License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 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 dico>
If you find this output superfluous and useless, you can suppress it by setting
quiet yes
in your initialization file.
7.2.7 Session Transcript
Session transcript is a special mode, which displays raw DICT commands and answers as they are executed. It is useful for debugging purposes.
You enable session transcript by issuing the following command:
dico> .transcript yes
# or
dico> .transcript on
Starting from then, each DICT transaction will be displayed on standard error output, for example:
dico> .open dico: Debug: S:220 Pirx.gnu.org.ua dicod (dico 2.10) <mime.xversion.xlev> <32004.1216639476@gnu.org.ua> dico: Debug: C:CLIENT "dico 1.99.91" dico: Debug: S:250 ok dico: Debug: C:SHOW DATABASES dico: Debug: S:110 26 databases present … dico: Debug: S:. dico: Debug: S:250 ok dico: Debug: C:SHOW STRATEGIES dico: Debug: S:111 10 strategies present: list follows dico: Debug: S:exact "Match words exactly" dico: Debug: S:prefix "Match word prefixes" dico: Debug: S:soundex "Match using SOUNDEX algorithm" … dico: Debug: S:. dico: Debug: S:250 ok
In the example above, ellipses are used to replace long lists of data. As you see, session transcripts may produce large amount of output.
To turn the session transcript off, use the following command:
dico> .transcript no
# or
dico> .transcript off
Finally, to query the current state of session transcript, issue this command without arguments:
dico> .transcript transcript is on
7.2.8 Other Commands
The prefix
command queries or changes the current command prefix:
dico> .prefix Command prefix is . dico> .prefix @ dico> @prefix Command prefix is @
The prompt
command changes the dico
command line
prompt. For example, to change it to ‘dico$’, followed by a single
space, type:
dico> .prompt "dico$ " dico$ _
Note the use of quotes to include the space character in the argument.
The help
command displays a short command usage summary. For
convenience, a single question mark can be used instead of it:
dico> ? /WORD Match WORD. / Redisplay previous matches. NUMBER Define NUMBERth match. !NUMBER Edit NUMBERth previous command. .open [HOST [PORT]] Connect to a DICT server. .close Close the connection. …
The version
command displays the package name and version
number, and the warranty
command displays the copyright
statement.
Finally, the quit
command leaves the dico shell. Typing
end-of-file character (C-d) has the same effect.
7.2.9 Dico Command Summary
For convenience, this subsection lists all available dico
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.
open host port
Connect to a DICT server. Both arguments are optional. If any of them is absent, the value supplied with the previous
open
command is used. If there was no previous value, the default is used, i.e., ‘gnu.org.ua’ for host, and 2628 for port.See open.
close
Close the connection.
See close.
autologin [file]
Set or display the autologin file name.
See Autologin.
sasl [bool]
Without argument, show whether the SASL authentication is enabled. With argument, enable or disable it, depending on the value of bool. See Autologin.
database [name]
Set or display the current database name.
See database.
strategy [name]
Set or display the current strategy name.
See strategy.
distance [num]
Set or query Levenshtein distance. This command takes effect only if the remote server supports ‘xlev’ experimental capability (see XLEV).
See distance.
ls
List available matching strategies.
See ls.
ld
List all accessible databases.
See ld.
info [db]
Display information about the database db, or the current database, if used without argument.
prefix [c]
Set or display the command prefix.
See prefix.
transcript [bool]
Set or display session transcript mode.
See Session Transcript.
verbose [number]
Set or display debugging verbosity level. Currently (as of version 2.10) it is a no-op.
prompt string
Change command line prompt.
See prompt.
pager string
Change or display pager settings.
See Pager.
history
Display command history.
See History Commands.
help
Display short command usage summary.
See help.
version
Print program version.
See version.
warranty
Print copyright statement.
See warranty.
quiet bool
Toggle display of
dico
welcome banner. This command can be used only in initialization file.See quiet.
quit
Quit the shell.
See quit.
This document was generated on September 4, 2020 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.