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

New Post: ExpectAction Problem

$
0
0
Is it correct to assume that only two "choice" can be used in an ExpectAction?

I'm trying to issue a traceroute command on a cisco router without the host specified. This causes the CLI to ask for additional information, including target and source host. A total of 10 questions are asked before the command is successfully executed.

I thought I could just chain ExpectActions as so:
 ss.Expect(
                            new ExpectAction(@"Protocol \[ip\]: ", (s) =>
                                {
                                    ss.WriteLine("ip");
                                    _reply += s;
                                }),
                            new ExpectAction(@"Target IP address: ", (s) =>
                                {
                                    ss.WriteLine(dIpAddress);
                                    _reply += s;
                                }),
                            new ExpectAction(@"Source address: ", (s) =>
                                {
                                    ss.WriteLine(sIpAddress);
                                    _reply += s;
                                }),
                            new ExpectAction(@"Numeric display \[n\]: ", (s) =>
                                {
                                    ss.WriteLine("n");
                                    _reply += s;
                                }),
                            new ExpectAction(@"Timeout in seconds [3]: ", (s) =>
                                {
                                    ss.WriteLine("3");
                                    _reply += s;
                                }),
                            new ExpectAction(@"Probe count [3]: ", (s) =>
                                {
                                    ss.WriteLine("3");
                                    _reply += s;
                                }),
                            new ExpectAction(@"Minimum Time to Live [1]: ", (s) =>
                                {
                                    ss.WriteLine("1");
                                    _reply += s;
                                }),
                            new ExpectAction(@"Maximum Time to Live [30]: ", (s) =>
                                {
                                    ss.WriteLine("30");
                                    _reply += s;
                                }),
                            new ExpectAction(@"Port Number [33434]: ", (s) =>
                                {
                                    ss.WriteLine("33434");
                                    _reply += s;
                                }),
                            new ExpectAction(@"Loose, Strict, Record, Timestamp, Verbose[none]: ", (s) =>
                                {
                                    ss.WriteLine(" ");
                                    _reply += s;
                                }),
                            new ExpectAction(new Regex(@"\\*  \\*  \\*"), (s) =>
                                {
                                    _reply = s;
                                    _reply += s;
                                })
                            );
However, only the first two are ever processed.

I assume I'm doing this wrong. I appreciate any input.

Viewing all articles
Browse latest Browse all 1729

Trending Articles



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