我正在使用SHARPSSH SshShell,我能够连接到我的unix机器..我能够发出我的命令(尽管验证结果有问题)
我可以发出TAR命令,我的问题是确定tar是否已完成。有没有办法使用SHARPSSH来检查这个?
如有任何帮助,将不胜感激..
发布于 2011-05-13 17:46:50
您没有显示代码,所以很难判断问题出在哪里。
我建议查看官方的sharpssh示例,特别是这1个。它似乎做了您想要做的事情:连接、发出命令并等待结果/这些命令的终止。
如果没有帮助,请提供更多信息。
1:http://sharpssh.svn.sourceforge.net/viewvc/sharpssh/trunk/Examples/sharpssh_samples/SshExeTest.cs?revision=3&view=markup
发布于 2011-07-20 17:30:02
SshExec exec = new SshExec("host","user");
exec.Password = "pass";
//if (input.IdentityFile != null) exec.AddIdentityFile(input.IdentityFile);
Console.Write("Connecting...");
exec.Connect();
Console.WriteLine("OK");
while (true)
{
Console.Write("Enter a command to execute ['Enter' to cancel]: ");
string command = "ls";
if (command == "") break;
string output = exec.RunCommand(command);
Console.WriteLine(output);
}
Console.Write("Disconnecting...");
exec.Close();
Console.WriteLine("OK");
enter code herehttps://stackoverflow.com/questions/5989101
复制相似问题