Confirmed. Thanks Clemens!

Option -interactive does work on named pipes as suggested, by keeping the
file handle open.
Below is a working reference procedure in bash for input and output if
anybody is interested.

On terminal 1:

$ mkfifo /tmp/slsh_in
$ mkfifo /tmp/slsh_out
$ ./sqlite3 -interactive </tmp/slsh_in >/tmp/slsh_out

On terminal 2:

$ cat </tmp/slsh_out&
[1] 14769
$ cat >/tmp/slsh_in;
SQLite version 3.19.3 2017-06-08 14:26:16
Enter ".help" for usage hints.
sqlite> select count() from sqlite_master;
select count() from sqlite_master;
0
sqlite>

On Wed, Jul 12, 2017 at 1:12 AM, Clemens Ladisch <clem...@ladisch.de> wrote:

> petern wrote:
> > $ echo "SELECT ('Shouldn''t SQLite shell continue interactively after
> > processing this statement?')msg;" >/tmp/slsh_in
> > $
> >
> > Results at first terminal after echo line is sent from second terminal:
> >
> > $ #Interactively run sqlite3 from named pipe.
> > $ mkfifo /tmp/slsh_in
> > $ ./sqlite3 -interactive </tmp/slsh_in
> > SQLite version 3.19.3 2017-06-08 14:26:16
> > Enter ".help" for usage hints.
> > sqlite> SELECT ('Shouldn''t SQLite shell continue interactively after
> processing this statement?')msg;
> > Shouldn't SQLite shell continue interactively after processing this
> statement?
> > sqlite>
> > $
> >
> > Apparently, from piped input with -interactive option, SQLite shell is
> > batch processing.
>
> No; when in batch mode, sqlite3 would not output the banner.
>
> A read() on a pipe returns zero (instead of blocking) when the writing
> process has closed it.  This means that after the echo has finished,
> sqlite3 detects an end-of-file, just as if you had pressed ^D
> interactively.
>
> To get what you want, you have to keep the pipe open for writing.
>
>
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to