Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: ShellStream to execute a command, which requires confirmation "YES"

$
0
0
We are writing a tool to automate the operation to HP OA. It works perfectly unless we meet a command which requires confirmation during its execution. It output "Do you want to continue ? " and we have to type "YES" to continue. We want to do this in our code. But with the following code it usually return "Operation terminated by user" after writing "YES".
                ShellStream ss = oar.Connection.CreateShellStream("", 100, 100, 100, 100, 9999);
                        StreamReader reader = new StreamReader(ss);
                        StreamWriter writer = new StreamWriter(ss);
                        writer.AutoFlush = true;

                           writer.WriteLine(isshcmdrecord.Command);
                            while (pollTime < isshcmdrecord.PollTime)
                            {
                                System.Threading.Thread.Sleep(3000);
                                buf = reader.ReadToEnd();
                                if (buf != "")
                                {                                    
                                    result += buf;
                                   foreach (KeyValuePair<string, string> kp in isshcmdrecord.PromptStringsAndInputs)
                                        {
                                            if (buf.Contains(kp.Key))
                                            {                                                    
                                                ss.WriteLine(kp.Value);     __//here we write "YES", but it usually return "Operation terminated by user", we tried use Write() instead of "WriteLine". In putty or telnet session, we got this message if simply hit ENTER.  __                                          
                                                break;
                                            }
                                        }
                                    }
                                  }
does any see similar issue? How can I solve this issue? Thanks for any help

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>