bio | home | mobile | papers | videos



PQ(1)                       General Commands Manual                      PQ(1)



NAME
       pq, pqgen, pqsrv - PQ IRDB directory access

SYNOPSIS
       pq -o format [ -a attrs ] [ -m modules ] [ -s seps ] [ -d debug ] query
       ...

       pqgen [ directory ]

       pqsrv [ modules ]

DESCRIPTION
       Pq connects to an Implicit Relational  Database  (IRDB)  directory  and
       outputs  the  record(s)  that match the query arguments.  The directory
       contacted may be specified by a modules argument (see dispatch(7)).

       Each query argument results in an independent query of  the  directory,
       consisting  of a set of input attributes, obtained from the query argu-
       ment, and a set of output attributes, obtained from the  output  format
       (see  the  -o  option).  The  output  of all the queries are formatted
       according to the output format and concatenated on standard output.

       Each query argument is a list of strings of  the  form  attribute=value
       separated  by any number of separator characters (default is |, but can
       be changed via the -s option).  The string attribute= may be elided, in
       which  case the attribute name is taken from the corresponding token in
       the -a option.  It is an error if there is no  corresponding  attribute
       name.   The  query  argument may be the empty string; in this case, all
       records that contain the output attributes are returned.   The  options
       are:

       -m modules
              Contact  the directory specified by the modules string; the for-
              mat is described in dispatch(7).  The default value for  modules
              is the empty string.

       -s seps
              Set  the separator character list for delimiting tokens in query
              arguments and the -a option string; |, is the default.

       -o format
              Use the output format specified.  See below for a full  descrip-
              tion.

       -a attrs
              Set the default attribute names for query components that do not
              specify them.

       -d debug
              Print information regarding  internal  operations.   Values  for
              debug range from 1 to 3, with 3 yielding the most detail.

   Output Formatting
       The  format  argument  specified  with  the  -o  option  is used like a
       print(2) string for formatting the output of  directory  queries.   All
       characters are copied literally, except for attribute substitutions and
       backslash escapes.  Quoting may be necessary to prevent shell interpre-
       tation.  The syntax for attribute substitutions is this:

              % flags minimum . maximum {attribute}

       Only % and attribute are required.  Curly braces, {}, are required only
       when the attribute is immediately followed by an  alphanumeric.   Flags
       may be one or more of the following:

         -      Right justify (left justification is the default).
         ^      Capitalize the first letter of each word.
         +      Capitalize all letters in the value.
         <      If the value is empty, delete back to the last \< or beginning
                of output.
         >      If the value is empty, skip to the next \> or  end  of  format
                string.

       Minimum is an integer giving the minimum field width.  If the value has
       fewer than the minimum number of characters, the field will  be  padded
       with blanks.  The default minimum is zero.

       Maximum  is  an integer that specifies the maximum number of characters
       to be output from the value.  If the value  has  more  characters  than
       this  number,  the  value  will  be  truncated.  A maximum of zero (the
       default) causes all characters to be output.  A period is used to sepa-
       rate minimum and maximum and is only required if maximum is specified.

       The  following  table  lists  backslash  escapes that are recognized by
       pq(1):

                +----------------------------------------------------+
                |          Output Format Backslash Escapes           |
                +-------+--------------------------------------------+
                |Escape |                  Meaning                   |
                +-------+--------------------------------------------+
                +-------+--------------------------------------------+
                |  \b   | Backspace                                  |
                +-------+--------------------------------------------+
                |  \c   | Suppress terminating newline               |
                +-------+--------------------------------------------+
                |  \f   | Formfeed                                   |
                +-------+--------------------------------------------+
                |  \n   | Newline                                    |
                +-------+--------------------------------------------+
                | \ooo  | ASCII character defined by an octal number |
                +-------+--------------------------------------------+
                |  \r   | Carriage return                            |
                +-------+--------------------------------------------+
                |  \t   | Tab                                        |
                +-------+--------------------------------------------+
                |  \v   | Vertical tab                               |
                +-------+--------------------------------------------+
                |  \<   | Marker for < flag                          |
                +-------+--------------------------------------------+
                |  \>   | Marker for > flag                          |
                +-------+--------------------------------------------+

       Pqgen is used to create index files for an existing IRDB  ev(7)  direc-
       tory.   Once  indexed,  the speed of lookups is greatly improved.  How-
       ever, it is then necessary to rerun pqgen after any changes are made to
       the ev database.  The directory is the location of the ev database.  If
       not an absolute pathname, it is interpreted relative to /lib/pq.

       Pqsrv is the server that handles incoming PQ requests.  It is meant  to
       be  run by listen(8), typically for TCP port 411.  The optional modules
       argument is the same as that to pq(1) above.

EXAMPLES
       Find the telephone number of employee with login of liz:

              pq -o %telephone 'login=liz'

       List addresses of employees in New Jersey and Texas who are full-time:

              pq    -o     '%20name     %25addr     %state     %zip'     'sta-
              tus=FT|state=NJ|state=TX'

       Consult /sys/src/cmd/pq/example for a more detailed example.

FILES
       /lib/pq/dispatch                   default dispatch file

       /rc/bin/service/tcp411             typical location for pqsrv

DIAGNOSTICS
       Pq  prints  a diagnostic to the standard error and exits with status no
       records if there are no matches.  Otherwise, it  returns  a  successful
       status.

SOURCE
       /sys/src/cmd/pq

SEE ALSO
       pq(2), dispatch(7), ev(7), listen(8).



                                                                         PQ(1)