I summarize my answer from the mail for other visitors:
It was caused by coincidence of the received data and selected prompt:
prompt = regex:(.@.:s+)
command sent (due to server echo, it is also received data): set prompt="whoami
@hostname
: "
The server can split output data into blocks of any length. In the case of "Unable to process command" error, it was unfortunately split that way, the block ended with "`whoami`@`hostname`: " which was matched as prompt.
This can be treated as imperfection of our prompt detector. If we have detected prompt at the end of one block, we can wait let say 50ms for another block to be sure this is really the last block of output and detected prompt is the real prompt, not only part of output data. This will improve prompt detection, because if this situation arises, it is very probably, that the next block is ready to read (actually it was originally one bigger response split into two blocks in unlucky way). However, it cannot be never 100% reliable, because what if the network got stuck suddenly, and the next block doesn’t come within 50ms interval. It is all because Shell session is not suitable/designed for automatic program processing. This could be easily resolved e.g. if the server is waiting for a user input, it would send a special signal – unfortunately it wouldn’t.
Conclusion:
The best practice of programming Shell processor is to use such prompt, which will never occur in the output data.
@Eugene:
In your case, you are currently changing the server's prompt, so I suggest you to change it to "-BEGIN-`whoami`@`hostname`-END-: " and use prompt = regex:^(-BEGIN-[^`]*@[^`]*-END-: )$
@Eugene: I have sent the patch with 50ms delay to your email recently.