This project is read-only.

Issue trying to send a command via SSH to VMWare

Aug 16, 2013 at 7:51 PM
I'm able to run commands like "who" when testing, but when I try to run something like "services.sh restart" it just hangs. Running it using Putty works fine.

Thanks,
Adrian
var connectionInfo = new KeyboardInteractiveConnectionInfo(host, username);
            connectionInfo.AuthenticationPrompt += delegate(object sender, AuthenticationPromptEventArgs e)
            {
                foreach (var prompt in e.Prompts)
                {
                    if (prompt.Request.Equals("Password: ", StringComparison.InvariantCultureIgnoreCase))
                    {
                        prompt.Response = password;
                    }
                }
            };

            using (var ssh = new SshClient(connectionInfo))
            {
                ssh.Connect();
                var cmd = ssh.RunCommand("services.sh restart");
                Console.WriteLine(cmd.Result);
                ssh.Disconnect();
            }
Aug 22, 2013 at 4:17 AM
So I followed the example using CreateShellStream from here:
http://sshnet.codeplex.com/discussions/439210

The problem is that it's based on stream.Length == 0 to determine that the command has completed, but in my case it's not. Is there a better way to detect that it's actually completed?
Sep 24, 2013 at 4:17 PM
Anyone?