Hmm... Globally, if you don't know what the server is asking, you shouldn't process further.
Let suppose this server question after connect:
"This server is not secured. Do you want to continue? (Y/N): "
or other server:
"This server is not secured. Do you want to quit? (Y/N): "
If you don't know what the server is asking, you cannot handle this automatically.
The solutions can be:
1. Ask the user to reply.
2. Inform user that unknown response from server was received and the program is exiting.
You can do it like this:
var script = client.StartScripting();
script.Prompt = "regex:[$#>] "; // matches prompts ended with $,#,>
script.Timeout = 10 * 1000; // 10 seconds
var seLogin = new Regex(@"(login:)|(username:)", RegexOptions.IgnoreCase);
var seChangePassword = new Regex(@"change.*password.*(Y/N)", RegexOptions.IgnoreCase);
var match = script.WaitFor(seLogin, seChangePassword, ScriptEvent.Prompt, ScriptEvent.Timeout);
// handle change password
else if (match.IsEventMatched(seLogin))
// handle login request
else if (match.IsPrompt)
// prompt was received
// do nothing and continue...
// handle unexpected server response
// ask user or quit
string response = script.ReadUntil(ScriptEvent.Prompt);