0

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

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

任何帮助,将不胜感激..

4

2 回答 2

1

您没有显示代码,因此很难判断问题可能出在哪里。

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

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

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

于 2011-05-13T09:46:50.490 回答
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
于 2011-07-20T09:30:01.930 回答