Re: psql client quits after 1st command

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Vincenzo Romano <vincenzo(dot)romano(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: psql client quits after 1st command
Date: 2007-03-02 16:47:17
Message-ID: 20070302164717.GB30029@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Mar 02, 2007 at 05:26:03PM +0100, Vincenzo Romano wrote:
> > psql gets an EOF on the named pipe when the first shell command
> > exits. You need to batch all your commands and send them in one shell
> > command, so it keeps the pipe open until it's done.
> >
> > -Doug
>
> Using "echo -n" instead of the plain "echo" to avoid sending the EOL makes the
> psql client behaving the same way: quitting after the first complete command.
> This makes useless the input redirection from anything other than a file.

No, it's exactly as he said: the FIFO only works once. As soon as
you've piped something into it and the echo closes the pipe, it closes
for psql also. As far as it's concerned you've quit, so it exits.

Replace the psql commmand with "cat" and you'll see exactly the same
effect.

I don't think you can acheive the effect you want with a FIFO. Maybe a
UDP socket will work as it doesn't require a permanent connection.

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2007-03-02 16:51:08 Re: Differences in identical queries
Previous Message Martijn van Oosterhout 2007-03-02 16:35:40 Re: Add items to a record variable