Open x3ntrix opened 11 months ago
Same problem here.
A simple Invoke-SSHCommandStream -Session $session -Command 'echo 1; echo 2; echo 3'
fails (only displays the 1).
Wrapping in sh -c
does not help.
Interesting I'm not able to replicate this
I'm talking to a https://teltonika-networks.com/products/routers/rut241 device.
Maybe it's a busybox issue or some issue with how the terminal is setup. I'll try to check the env/pty diffs with a normal ubuntu server.
Behavior wise, what happens with -Command 'echo 1; sleep 3; echo 2; sleep 3; echo 3'
is that it immediatly prints the 1, then waits 6 seconds, then quits. The 2 & 3 are never printed, but the sleep happened.
It looks like it is confused by newlines (or stream flushes?), like it correctly gets the first one but not subsequent ones.
I expect that might be improved on the develop branch of SSH.NET, pending the next release. The logic behind the output stream was pretty wonky and has been rewritten
I noticed that Invoke-SSHCommandStream does not work correctly for some commands. For example:
It will only print a part of the first line ("Listing...") and finish, but the output should be:
I assume that it has something to do with how the apt command prints its output. If the behavior of Invoke-SSHCommandStream cannot be improved, it should be documented as a limitation.