Inside a shell script, I want to start a persistent mysql client process and feed it commands one by one.
I’d like to use a named pipe, but the only way I’ve found to do it so far is with a subshell, by putting 99% of the script inside the subshell and piping the subsell’s entire output to mysql. While this more-or-less works, it’s very much not ideal.
If I use a named pipe, every time I echo something to that pipe (e.g. “echo INSERT INTO… > /tmp/mypipe”), mysql immediately exits upon reaching EOF, so only the very first command gets executed.
I recall posting a way to accomplish this with psql & inetd a year or two ago, but I don’t want to use inetd – this *must* be entirely self-contained within a single shell script. Also I can’t figure out a way to tell mysql to ignore EOF on STDIN and to immediately reopen it.
Anyone have any better ideas?
Thanks,
-Adam