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

New Post: Get ShellStream to respond to multiple nested prompts

$
0
0
The problem is I want to use the ShellStream to change a user's password:
user@linux:~$ passwd
>current UNIX password:
>Enter new UNIX password:
>Retype new UNIX password:
user@linux:~$
The ShellStream cannot intercept all the "> prompts" using an ExpectAction(). The only thing I've been able to do is respond to exactly one prompt but it hangs after that.
stream.Expect(
                            new ExpectAction("password for user1:", (s) =>
                            {
                                Console.Write(s);
                                writer.WriteLine("pass");
                            })
                        );

stream.Expect(
                                new ExpectAction("user1@hostname:~$", (s) =>
                                {
                                    Console.Write(s);
                                })
                            );

writer.Write( *** NEXT COMMAND HERE ***);
How do I intercept all three prompts above and answer them?

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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