Skip to main content
1 of 4
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

What you want is already happening, actually. And certainly mkdir isn't your problem - it doesn't read stdin anyway. That pipe is inherited as stdin by all of the children of ssh - unless, that is, you are getting a pseudo terminal like ssh -T. Barring that, then the problem is that the shell is by default passing that along to the first command group it runs and it just gets dropped. Most simple, I think, would just be to move the descriptor to something that won't be automatically dropped, like:

echo hey there >file cat file | ssh mikeserv@localhost ' exec 3<&0 mkdir -p . echo ho there cat <&3' 

If I run the above it prints:

ho there hey there 
mikeserv
  • 59.4k
  • 10
  • 122
  • 242