Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Shell functionlity

$
0
0

 

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);
ssh.Connect();
tername = sessionInfo.m_host + "@"+ sessionInfo.m_user;
shells = ssh.CreateShellStream(tername, 80, 24, 800, 600, 1024);

//checking for promt
shells.WriteLine(command);
String outp = "";
Regex regex = new Regex(@"\[.*@.*\][\$|\#]");
//my promt is variablevar 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. 
 

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>