I want to capture the output of a shell SSH script to a file and have it on stdout at the same. I know I can use tee
but it doesn't seem to be working as I expect in this case.
Example,
#!/bin/sh
ssh user@host | tee /tmp/a << EOF
echo hi
EOF
I expect hi
to be in /tmp/a
, instead it looks like ssh
waits forever for input.
If I replace ssh
with cat
it works as I expect
#!/bin/sh
cat | tee /tmp/a << EOF
hi
EOF
Output: hi
$ cat /tmp/a
hi
What's the difference between ssh
and cat
here?
You can use: