(gawk.info.gz) Getline/Coprocess

Info Catalog (gawk.info.gz) Getline/Variable/Pipe (gawk.info.gz) Getline (gawk.info.gz) Getline/Variable/Coprocess
 
 3.8.7 Using `getline' from a Coprocess
 --------------------------------------
 
 Input into `getline' from a pipe is a one-way operation.  The command
 that is started with `COMMAND | getline' only sends data _to_ your
 `awk' program.
 
    On occasion, you might want to send data to another program for
 processing and then read the results back.  `gawk' allows you to start
 a "coprocess", with which two-way communications are possible.  This is
 done with the `|&' operator.  Typically, you write data to the
 coprocess first and then read results back, as shown in the following:
 
      print "SOME QUERY" |& "db_server"
      "db_server" |& getline
 
 which sends a query to `db_server' and then reads the results.
 
    The values of `NR' and `FNR' are not changed, because the main input
 stream is not used.  However, the record is split into fields in the
 normal manner, thus changing the values of `$0', of the other fields,
 and of `NF'.
 
    Coprocesses are an advanced feature. They are discussed here only
 because this is the minor node on `getline'.   Two-way I/O,
 where coprocesses are discussed in more detail.
 
Info Catalog (gawk.info.gz) Getline/Variable/Pipe (gawk.info.gz) Getline (gawk.info.gz) Getline/Variable/Coprocess
automatically generated by info2html