I'm trying to use socat on two systems in order to send a multivolume tar from one system to the other. Multivolume is an absolute requirement as I'm trying to shift potentially petabytes of data to a mounted tape archive.
Ultimately, I'm want to do something like this:
# on system1:
socat PIPE:/tmp/pipe1 SYSTEM:"ssh system2 socat - PIPE\:/tmp/pipe2" &
tar -M -L 10G -F /tmp/chvol -cvf /tmp/pipe1 &
# on system2:
cat /tmp/pipe2 > file001.tar
cat /tmp/pipe2 > file002.tar
(The chvol script just echos the path /tmp/pipe1.)
As I've not been able to get this working yet, I'm running the following much-simplified test on one single system:
socat PIPE:/tmp/pipe1 PIPE:/tmp/pipe2 &
sh -c 'while sleep 1; do echo "sending date ..."; date > /tmp/pipe1; done' &
sh -c 'while sleep 1; do echo "slurping ..."; cat < /tmp/pipe2; done' &
which is meant to simulate a writer process repeatedly opening, writing, closing and a reader process repeatedly opening, reading until EOF, closing.
But this doesn't behave as I expected: the writer is seemingly happy, but the reader reads all the accumulated text in one go and thereafter remains blocked in a
cat < ... call.
Can anybody explain (1) what is actually happening in the much-simplified test and (2) what I should be doing instead?
I have tried various
shut-* options on both pipes (on the assumption that the problem is in the propogation of EOF) and done a lot of googling.