0

Below is the perl script to enable some destination. This requires user confirmation.

*****.pl --enable ***

DO YOU WANT TO ENABLE DESINATION(S) [Y\N] :

we have been using

var sshClient = new SshClient(host, username, password);
sshClient.CreateCommand("command").Execute();

[Question] How to provide user confirmation to sshClient

Dmitry
  • 13,797
  • 6
  • 32
  • 48
Debananda
  • 476
  • 1
  • 6
  • 17

2 Answers2

0

I do not think you can do it with the SSH.Net library. You might need SharpSSH library, which has a function - Expect. This is similar to Perl SSH::Expect, if you are familiar with it.

You can wait for (expect) command output, provide an input while particular output (like your Do You want to Enable...) occurs

Please see this link explaining an example:

http://www.tamirgal.com/blog/post/SSH-Expect-Example.aspx

We can discuss more in comments section and I will add more details on the go

0

Ideally, the script would provide a means of avoiding the prompts through command line arguments of environment variables. If it doesn't, you'll need to provide appropriate inputs to its STDIN. It might simply be a case of executing the following command instead:

echo Y | command

expect (the command line tool, or a similar .NET library if one exists) can be used to handle more complicated situations.

ikegami
  • 367,544
  • 15
  • 269
  • 518