I'm trying to use rsync over a custom shell created with fifo. However I cannot find a way to deal with it :
The script initsh to simulate a standard shell by fifo :
#!/bin/bash
rm fin
mkfifo fin
rm fout
mkfifo fout
rm ferr
mkfifo ferr
rm farg
mkfifo farg
read arg <farg
cat fin | /bin/bash -i -c "$arg" 1>fout 2>ferr
This script works well, you can test it by running (cat fout &) && echo ls > farg
The script rsh to pass to rsync :
#!/bin/bash
shift;
cat fout &
cat ferr 1>&2 &
echo "$@" | tee -a out > farg
cat | tee -a out > fin
sleep 2
kill %%
exit
The way to call rsync with :
rsync -e './rsh' user@fakehost:/
It works well when you run echo ./rsh, you got the shell like rsync wait for.
But when rsync runs it, it does not close stdin, and so it waits for the stop (the EOF) of "cat | ...". I also tried with exec 0<>fin but it does not work at all.
Is there a trick to close the handle properly ? Or have you any other approach ?