3

I created a program using Renci SSH.NET library. Its sending all the commands and reading the result normally. However, when I send the command below:

client.RunCommand("cli");

The program hangs on this line indefinitely.

Any explanation of what is happening?

The cli is a command is used on Juniper switches/routers.

0

1 Answer 1

5

AFAIK, cli is a kind of a shell/interactive program. So I assume you have tried to do something like:

client.RunCommand("cli");
client.RunCommand("some cli subcommand");

That's wrong. cli will keep waiting for subcommands and never exit, until you explicitly close it with a respective command (like exit). And after it exits, the server will try to execute the cli subcommand as a separate top-level command, failing too.


You have to feed the "cli subcommand" to the input of the cli command. But SSH.NET unfortunately does not support providing an input with the SshClient.RunCommand/SshClient.CreateCommand interface. See Allow writing to SshCommand.


There are two solutions:

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. ShellStream works perfectly fine in case of subcommands

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.