This project is read-only.

Get ShellStream to respond to multiple nested prompts

Jan 5, 2015 at 4:52 AM
Edited Jan 5, 2015 at 4:52 AM
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?