1 <!-- $Id: client.xml,v 1.10 2002-02-04 21:05:28 adam Exp $ -->
2 <chapter id="client"><title>The YAZ client</title>
3 <sect1 id="client.introduction"><title>Introduction</title>
5 yaz-client is a line-mode Z39.50 client. It supports a fair amount
6 of the functionality of the Z39.50-1995 standard
7 Its primary purpose is to exercise the package, and verify that
9 For the same reason some commands offers more functionality than others.
10 Commands that exercises common Z39.50 services such as search and present
11 have more features than less common supported services, such as Extended
12 Services (ItemOrder, ItemUpdate,..).
15 <sect1 id="client.invoking"><title>Invoking the YAZ client</title>
17 It can be started by typing
20 yaz-client [<replaceable>options</replaceable>] [<replaceable>zurl</replaceable>]
23 in a UNIX shell / WIN32 console. The <replaceable>zurl</replaceable>,
24 specifies a Z39.50 host and, if specified, the client first tries to
25 establish connection with the Z39.50 target on the host.
26 Options are, as usual, are prefixed by
27 <literal>-</literal> followed by a particular letter.
30 The following options are supported:
34 <literal>-m</literal> <replaceable>fname</replaceable>
36 <simpara>All retrieved transfer records are appended to file
37 <replaceable>fname</replaceable>. All records as returned by a
38 target(s) in Search Responses and Present Responses are appended
43 <literal>-a</literal> <replaceable>fname</replaceable>
45 <simpara>Pretty-print log of APDUs sent and received is appended
46 to the file <replaceable>fname</replaceable>.
47 If <replaceable>fname</replaceable> is <literal>-</literal> (minus)
48 the APDU log is written to <literal>stderr</literal>.
52 <literal>-c</literal> <replaceable>fname</replaceable>
54 <simpara>Sets the filename for CCL fields to
55 <replaceable>fname</replaceable>. If this option is not given the
56 YAZ client reads CCL fields from file <literal>default.bib</literal>.
60 <literal>-v</literal> <replaceable>level</replaceable>
62 <simpara>Sets the LOG level to <replaceable>level</replaceable>.
63 Level is a sequence of tokens separated by comma. Each token
64 is a integer or a named LOG item - one of
65 <literal>fatal</literal>,
66 <literal>debug</literal>,
67 <literal>warn</literal>,
68 <literal>log</literal>,
69 <literal>all</literal>,
70 <literal>none</literal>.
74 <literal>-p</literal> <replaceable>target</replaceable>
76 <simpara>Specifies proxy address. When set YAZ client will
77 connect to a proxy on the address and port given.
78 The actual target will be specifed as part of the InitRequest
79 to inform the proxy about actual target.
83 <literal>-u</literal> <replaceable>authentication</replaceable>
85 <simpara>Specifies authentication. Usually the form
86 <replaceable>user</replaceable>/<replaceable>password</replaceable>
87 is used. This option does the same thing as the
88 <literal>auth</literal> command.
93 <literal>-k</literal> <replaceable>kilobytes</replaceable>
95 <simpara>Specifies the maximum messages size in kilobytes.
96 The default maxium messages for the YAZ client is 1024
103 In order to connect to Index Data's test Z39.50 server on
104 <literal>bagel.indexdata.dk</literal>, port 210 and with the
105 database name marc, one would have to type
108 yaz-client bagel.indexdata.dk:210/marc
111 In order to enable APDU log and connect to localhost, port 210 (default)
112 and database Default (default) you'd write:
115 yaz-client -a - localhost
118 <sect1 id="client.commands"><title>Commands</title>
120 When the YAZ client has read options and connected to a target, if given,
121 it will display <literal>Z></literal> and await your command.
122 Commands are executed by hitting the return key.
123 You can always issue the command <literal>?</literal> to see the list
124 of available commands.
127 The commands are (the letters in parenthesis are short
128 names for the commands):
132 <literal>open </literal><replaceable>zurl</replaceable>
135 <para>Opens a connection to a server. The syntax for
136 <replaceable>zurl</replaceable> is the same as described
137 above for connecting from the command line.
143 [<literal>(tcp|ssl)':'</literal>]<replaceable>host</replaceable>
144 [:<replaceable>port</replaceable>][/<replaceable>base></replaceable>]
149 <literal>quit</literal>
152 <para>Ends YAZ client</para>
156 <literal>f </literal><replaceable>query</replaceable></term>
158 <para>Sends a Search Request using the <replaceable>query</replaceable>
164 <literal>delete</literal> <replaceable>setname</replaceable></term>
166 <para>Deletes result set with name <replaceable>setname</replaceable>
167 on the server.</para>
171 <literal>base </literal><replaceable>base1</replaceable>
172 <replaceable>base2</replaceable> ...
175 <para>Sets the name(s) of the database(s) to search. One or more
176 databases may be specified separated by blanks. This commands overrides
177 the database given in <replaceable>zurl</replaceable>.
182 <literal>show </literal>
183 [<replaceable>start</replaceable>[+<replaceable>number</replaceable>]]
185 <term><literal>s</literal></term>
187 <para>Fetches records by sending a Present Request from the start
189 <replaceable>start</replaceable>
190 a number of records given by <replaceable>number</replaceable>. If
191 <replaceable>start</replaceable> is not given, then the client
192 will fetch from position of the last retrieved record plus 1. If
193 <replaceable>number</replaceable> is not given, then one record will
194 be fetched at a time.
199 <literal>scan</literal> <replaceable>term</replaceable>
203 database index for a term. The syntax resembles the syntax
204 for <literal>find</literal>.
205 If you want to scan for the word <literal>water</literal> you could
212 but if you want to scan only in, say the title field, you would write
219 <varlistentry id="sortspec"><term>
220 <literal>sort</literal> <replaceable>sortspecs</replaceable>
223 <para>Sorts a result set. The sort command takes a
224 sequence of sort specifications. A sort
225 specification holds a field (sort criteria) and is followed by flags.
226 If the sort criteria includes <literal>=</literal> it is assumed
227 that the sort SortKey is of type sortAttributes using Bib-1.
228 The integer before <literal>=</literal> is
229 the attribute type and the integer following <literal>=</literal>
230 is the attribute value.
231 If no <literal>=</literal> is in the SortKey it is treated as a
232 sortfield-type of type InternationalString.
233 Flags observed are: <literal>s</literal>
234 for case sensitive, <literal>i</literal> for case insensitive,
235 <literal><</literal> for sort ascending and <literal>></literal>
241 <literal>sort+</literal>
244 <para>Same as <literal>sort</literal> but stores the sorted
245 result set in a new result set.
250 <literal>authentication</literal> <replaceable>openauth</replaceable>
253 <para>Sets up a authentication string if a server requires
254 authentication (v2 OpenStyle). The authentication string is first
255 sent to the server when the <literal>open</literal> command is
256 issued and the Z39.50 Initialize Request is sent, so this command
257 must be used before <literal>open</literal> in order to be effective.
258 A common convention for the <replaceable>authopen</replaceable> string
259 is that the username - and password is separated by a slash, e.g.
260 <literal>myusername/mysecret</literal>.
265 <literal>lslb</literal> <replaceable>n</replaceable>
268 <para>Sets the limit for when no records should be returned
269 together with the search result.
272 url="http://lcweb.loc.gov/z3950/agency/markup/04.html#3.2.2.1.6">
281 <literal>ssub</literal> <replaceable>n</replaceable>
284 <para>Sets the limit for when all records should be returned with
288 url="http://lcweb.loc.gov/z3950/agency/markup/04.html#3.2.2.1.6">
290 </ulink> for more details.
296 <literal>mspn</literal> <replaceable>n</replaceable>
299 <para>Sets the number of records should be returned if the
300 number of records in the result set is between the values of
301 <literal>lslb</literal> and <literal>ssub</literal>.
304 url="http://lcweb.loc.gov/z3950/agency/markup/04.html#3.2.2.1.6">
312 <literal>status</literal>
315 <para>Displays the values of <literal>lslb</literal>,
316 <literal>ssub</literal> and <literal>mspn</literal>.
321 <literal>setname</literal>
324 <para>Switches named result sets on and off. Default is on.
329 <literal>cancel</literal>
332 <para>Sends a Trigger Resource Control Request to the target.
337 <literal>format</literal> <replaceable>oid</replaceable>
340 <para>Sets the preferred transfer syntax for retrieved records.
341 yaz-client supports all the record syntaxes that currently
344 url="http://lcweb.loc.gov/z3950/agency/defns/oids.html#5">
347 for more details. Commonly used records syntaxes include usmarc,
353 <literal>elements</literal> <replaceable>e</replaceable>
356 <para>Sets the element set name for the records. Many targets support
357 element sets are B (for brief) and F (for full).
362 <literal>close</literal>
365 <para>Sends a Z39.50 Close APDU and closes connection with the peer
370 <literal>querytype</literal> <replaceable>type</replaceable>
373 <para>Sets the query type as used by command <literal>find</literal>.
374 The following is supported: <literal>prefix</literal> for
375 <link linkend="PQF">Prefix Query Notation</link> (Type-1 Query);
376 <literal>ccl</literal> for CCL search (Type-2
377 Query) or <literal>ccl2rpn</literal> for
378 <link linkend="CCL">CCL</link> to RPN conversion (Type-1 Query).
383 <literal>attributeset</literal> <replaceable>set</replaceable>
387 Sets attribute set OID for prefix queries (RPN, Type-1).
392 <literal>refid</literal> <replaceable>id</replaceable>
395 <para>Sets reference ID for Z39.50 Request(s).
400 <literal>itemorder</literal>
401 <replaceable>type</replaceable> <replaceable>no</replaceable>
404 <para>Sends an Item Order Request using the ILL External.
405 <replaceable>type</replaceable> is either 1 or 2 which corresponds to
406 ILL-Profile 1 and 2 respectively. The <replaceable>no</replaceable>
407 is the Result Set position of the record to be ordered.
412 <literal>update</literal>
415 <para>Sends Item Update Request. This command sends a "minimal"
416 PDU Update to the target supplying the last received record from
418 If no record has been received from the target this command is ignored
419 and nothing is sent to the target.
426 <replaceable>filename</replaceable>
429 <para>Executes list of commands from
430 file <replaceable>filename</replaceable>, just like source on
438 <replaceable>args</replaceable>
441 <para>Executes command <replaceable>args</replaceable> in subshell
442 using the <literal>system</literal> call.
448 <literal>push_commande</literal>
449 <replaceable>command</replaceable>
452 <para>The push_command takes another command as its argument.
453 That command is then added to the history information (so
454 you can retrieve it later). The command itself is not
455 executed. This command only works if you have GNU readline/history
462 <literal>set_apdufile</literal>
463 <replaceable>filename</replaceable>
466 <para>Sets that APDU should be logged to file
467 <replaceable>filename</replaceable>. This command does the
468 thing as option <literal>-a</literal>.
474 <literal>set_marcdump</literal>
475 <replaceable>filename</replaceable>
478 <para>Specifies that all retrieved records should be appended ot
479 file <replaceable>filename</replaceable>. This command does the
480 thing as option <literal>-m</literal>.
486 <literal>set_cclfields</literal>
487 <replaceable>filename</replaceable>
490 <para>Specifies that CCL fields should be read from file
491 file <replaceable>filename</replaceable>. This command does the
492 thing as option <literal>-c</literal>.
498 <literal>register_oid</literal>
499 <replaceable>name</replaceable>
500 <replaceable>class</replaceable>
501 <replaceable>OID</replaceable>
504 <para>This command allows you to register your own object
505 identifier - so that instead of entering a long dot-notation
506 you can use a short name instead.
507 The <replaceable>name</replaceable> is your
508 name for the OID, <replaceable>class</replaceable> is the
509 class, and <replaceable>OID</replaceable> is the raw OID in
510 dot notation. Class is one <literal>appctx</literal>,
511 <literal>absyn</literal>, <literal>attet</literal>,
512 <literal>transyn</literal>, <literal>diagset</literal>,
513 <literal>recsyn</literal>, <literal>resform</literal>,
514 <literal>accform</literal>, <literal>extserv</literal>,
515 <literal>userinfo</literal>, <literal>elemspec</literal>,
516 <literal>varset</literal>, <literal>schema</literal>,
517 <literal>tagset</literal>, <literal>general</literal>.
518 If you're in doubt use the <literal>general</literal>
526 <sect1 id="client.searching"><title>Searching</title>
528 The simplest example of a Prefix Query would be something like
536 In those queries no attributes was specified.
537 This leaves it up to the server what fields to search but
538 most servers will search in all fields. Some servers does not
539 support this feature though, and require that some attributes
540 are defined. To add one attribute you could do:
544 where we search in the title field, since the use(1) is title(4).
545 If we want to search in the author field <emphasis>and</emphasis>
546 in the title field, and in the title field using right truncation
547 it could look something like this:
549 f @and @attr 1=1003 knuth @attr 1=4 @attr 5=1 computer
551 Finally using a mix of Bib-1 and GILS attributes could look
554 f @attrset Bib-1 @and @attr GILS 1=2008 Washington @attr 1=21 weather
556 For the full specification of the Prefix Query see the section
557 <link linkend="PQF">Prefix Query Format</link>.
562 <!-- Keep this comment at the end of the file
567 sgml-minimize-attributes:nil
568 sgml-always-quote-attributes:t
571 sgml-parent-document: "yaz.xml"
572 sgml-local-catalogs: nil
573 sgml-namecase-general:t