I'm working on a wrapper library (in C#, but not really important to the issue here) to open an SSH connection and then allow for sending commands to the server and receiving the response. The main thing, however, is that I want to have the command call buffer the response stream and then return it all as one string to the user once the shell has returned to the console prompt. That way, I can just fire off a command and not have to deal with all the response events every time the server writes back to the console during the job.
So, my main question is, in a VT100 session, is there any fool-proof way of determining that the server has returned to the input prompt? The only thing I've found so far is that, with the two ssh servers I've tried (cygwin and Fedora), the last character sequence it always seems to output is '[esc][0m' [esc], being ASCII code 27 I would like to think that this is something standard, but when I looked up what that sequence is I found this:
modesoff SGR0, Turn off character attributes
I was kind of hoping for something more concrete, like "Waiting for input" :P
Any ideas if this should work for all/most systems? Or if there is a better way?