1

So i am trying to have the output of my ssh command consumed at different points in time and potentially within a subshell as well. I tried with fifos and with exec like:

exec 10< <(ssh host 'i=0;while :;do ((i++));echo $i;done')

read a <&10
echo $a
read a <&10
echo $a

the output i am looking is: 1 and 2. currently i get 1 and 1, a new process starts every time i read from the fd 10. Same thing with fifo. Any ideas of how to sort this out?


EDIT: I restarted my pc and the problem disappeared. It might had been yet another issue with wsl2

  • Your script as-is works as intended for me: I get 1 and 2. However, you might try read -u 10 a instead of redirecting. – B. Morris Oct 17 at 23:50
  • it looks like it was a wsl2 issue (not the first I had so far), I restarted my pc and it worked... – tturbox Oct 18 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.