/// <summary> /// Waits until there is some sort of prompt text, and extracts it. /// </summary> /// <param name="s"></param> /// <returns></returns> private static async Task <string> ExtractPromptText(ShellStream s, SshClient c) { await s.WaitTillPromptText(); s.WriteLine("# this initialization"); await DumpTillFind(s, c, "# this initialization", crlfExpectedAtEnd : true, secondsTimeout : 30); var prompt = await s.ReadRemainingText(1000); if (prompt == null || prompt.Length == 0) { throw new LinuxCommandErrorException($"Did not find the shell prompt! I will not be able to properly interact with this shell! ({c.ConnectionInfo.Host})"); } Trace.WriteLine("Initialization: prompt=" + prompt, "SSHConnection"); if (prompt.Contains("\n")) { Trace.WriteLine($"Prmopt contains a \\n character: '{prompt}'"); throw new InvalidOperationException($"Prmopt contains a \\n character: '{prompt}'"); } return(prompt); }