SharpSSH - SSHExec,运行命令,等待 5 秒获取数据!
我有这段代码:
using System;
using System.Text;
using Tamir.SharpSsh;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SshExec exec = new SshExec("192.168.0.1", "admin", "haha");
exec.Connect();
string output = exec.RunCommand("interface wireless scan wlan1 duration=5");
Console.WriteLine(output);
exec.Close();
}
}
}
命令将执行!我可以看到这一点,但是!它立即打印数据。或者实际上,它不会打印命令中的数据。它打印起来就像... mikrotik os 的徽标。我实际上需要命令中的数据,并且我需要 SharpSSH 等待至少 5 秒的数据,然后将其返回给我...... 有人知道我该怎么做吗?
我对此很陌生!我感谢所有帮助!谢谢你!
I have this code:
using System;
using System.Text;
using Tamir.SharpSsh;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SshExec exec = new SshExec("192.168.0.1", "admin", "haha");
exec.Connect();
string output = exec.RunCommand("interface wireless scan wlan1 duration=5");
Console.WriteLine(output);
exec.Close();
}
}
}
The command will execute! I can see that, but! It immediately prints data. Or actually, it does'nt print the data from the command. It prints like the... logo for the mikrotik os. I actually need the data from the command, and I need SharpSSH to wait at least 5 seconds for data, then give it back to me...
Somebody knows how I can do this?
I'm pretty new to this! I appreciate all help! Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想尝试以下重载:
如果他们的 API 执行其名称所暗示的操作,则它应该将命令的标准输出
stdOut 中的标准错误和 stdError 中的标准错误。
有关标准流的更多信息,请查看:http://en.wikipedia.org/wiki/Standard_streams< /a>
You may want to try the following overload:
If their API does what the name implies, it should put the standard output of your command
in stdOut and the standard error in stdError.
For more information about standard streams, check this out: http://en.wikipedia.org/wiki/Standard_streams