From: Phil Howard on
It looks like postmap can read stdin when getting a list of keys for
delete or query. There appeared to be no documented way to read from
stdin to create a new map. So I tried the following:

========================================================================
marconi/root/x0 /root 37# ls -dl foobar*
ls: cannot access foobar*: No such file or directory
marconi/root/x0 /root 38# ln -s /dev/stdin foobar
marconi/root/x0 /root 39# ( echo one foo ; echo two bar ) | postmap cdb:foobar
marconi/root/x0 /root 40# ls -dl foobar*
lrwxrwxrwx 1 root root 10 2010-06-03 14:46 foobar -> /dev/stdin
-rw-r--r-- 1 root root 2108 2010-06-03 14:47 foobar.cdb
marconi/root/x0 /root 41# postmap -q one cdb:foobar
foo
marconi/root/x0 /root 42# postmap -q two cdb:foobar
bar
marconi/root/x0 /root 43#
========================================================================

That obviously seems to work. Anyone know of any reason not to do it
this way (like maybe in the future it will refuse to run if the named
file isn't directly a regular file)?

From: Wietse Venema on
Phil Howard:
> It looks like postmap can read stdin when getting a list of keys for
> delete or query.

As documented in the postmap manpage:

-d key
...
If a key value of - is specified, the program reads key values
from the standard input stream.

-i Incremental mode. Read entries from standard input and do not
truncate an existing database.

-q key
...
If a key value of - is specified, the program reads key values
from the standard input stream and writes one line of key value
output for each key that was found.

> There appeared to be no documented way to read from
> stdin to create a new map.

Wietse

From: Phil Howard on
On Thu, Jun 3, 2010 at 14:58, Wietse Venema <wietse(a)porcupine.org> wrote:
> Phil Howard:
>> It looks like postmap can read stdin when getting a list of keys for
>> delete or query.
>
> As documented in the postmap manpage:
>
>       -d key
>              ...
>              If a key value of - is specified, the program reads  key  values
>              from  the standard input stream.
>
>       -i     Incremental  mode.  Read  entries from standard input and do not
>              truncate an existing database.
>
>       -q key
>              ...
>              If  a  key value of - is specified, the program reads key values
>              from the standard input stream and writes one line of key  value
>              output for each key that was found.
>
>>  There appeared to be no documented way to read from
>> stdin to create a new map.

So that limits using stdin to incrementing an existing map (such as
creating an empty one), or using the /dev/stdin trick. I'm just
wondering if there any pitfalls to the /dev/stdin method.