SharpSSH卡在C#SSH应用程序中读取的无限流中
下午好, 我对.Net的SharpSSH库有一个小问题 (见附件) 正如你所看到的,这是相当直接的 然而,当while循环进入时,当所有内容都已打印到控制台并且没有其他内容可读取时,它不会中断循环 当没有其他内容可阅读时,我是否可以手动强制它断开 干杯,SharpSSH卡在C#SSH应用程序中读取的无限流中,c#,.net,ssh,sharpssh,C#,.net,Ssh,Sharpssh,下午好, 我对.Net的SharpSSH库有一个小问题 (见附件) 正如你所看到的,这是相当直接的 然而,当while循环进入时,当所有内容都已打印到控制台并且没有其他内容可读取时,它不会中断循环 当没有其他内容可阅读时,我是否可以手动强制它断开 干杯, Ric
Ric
while(true)
while(true)
{
//Write command to the SSH stream
ssh.Write( "some command or execute a script on aix" );
data = "";
data = ssh.ReadResponse();
if (data.Length < 10) //don't wnat response like $
continue;
textWriter.Write(data); //write all of data to file on each response loop
if (data.Contains("EOF")) //was insert at end of file so I can terminate
break;
}
textWriter.Close();
ssh.Close(); //Close the connection
}
{
//将命令写入SSH流
Write(“在aix上执行某个命令或脚本”);
数据=”;
data=ssh.ReadResponse();
if(data.Length<10)//不要像$
继续;
text writer.Write(data);//将所有数据写入每个响应循环上的文件
if(data.Contains(“EOF”)/)被插入到文件的末尾,这样我就可以终止了
打破
}
textWriter.Close();
ssh.Close()//关闭连接
}
欢迎来到stackoverflow!请在上面的代码中添加简短说明,以提高帖子的准确性:)
while(true)
{
//Write command to the SSH stream
ssh.Write( "some command or execute a script on aix" );
data = "";
data = ssh.ReadResponse();
if (data.Length < 10) //don't wnat response like $
continue;
textWriter.Write(data); //write all of data to file on each response loop
if (data.Contains("EOF")) //was insert at end of file so I can terminate
break;
}
textWriter.Close();
ssh.Close(); //Close the connection
}