This project is read-only.

How to check whether output contains user promt or not. here my user promt is variable

Dec 17, 2012 at 4:59 AM

Hi all,


i have created ShellStream, from SshClient. i m facing a problem while checking that output of the shell stream contains my user promt or not. Previously i was checking it using Regex class match method, but its not useful in case of variable user promt. my user promt varies command by commands. here the code snippet.



// creating shell stream.
ssh = new SshClient(connectionInfo);
tername = sessionInfo.m_host + "@" + sessionInfo.m_user;
shells = ssh.CreateShellStream(tername, 80, 24, 800, 600, 1024);

//checking for promt
String outp = "";
Regex regex = new Regex(@"\[.*@.*\][\$|\#]");
//my promt is variable
 var match = regex.Match(outp);
 while (shells.DataAvailable || !match.Success || outp=="")
outp += shells.Read();
match = regex.Match(outp);
when i open sh shell. its user promt
sh-4.2$ like this.

kindly suggest any solution for it.