SharpSSH ..如何确定流程是否完成

时间:2011-05-13 08:14:40

标签: c# ssh sharpssh

我使用SHARPSSH SshShell,我能够连接到我的unix盒子..我能够发出我的命令(虽然在验证结果时遇到了问题)

我能够发出一个TAR命令,我的问题是确定tar是否完成..有没有办法用SHARPSSH检查这个???

任何帮助将不胜感激..

2 个答案:

答案 0 :(得分:1)

您没有显示代码,因此很难判断问题的位置。

我建议查看官方的sharpssh样本,特别是这个[1]。它似乎完全符合您的要求:连接,发出命令等待结果/终止这些命令。

如果这没有帮助,请提供更多信息。

1:http://sharpssh.svn.sourceforge.net/viewvc/sharpssh/trunk/Examples/sharpssh_samples/SshExeTest.cs?revision=3&view=markup

答案 1 :(得分:0)

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 here
相关问题