I'm trying to get result from a command through VB.NET, it is returning empty string as shown in the below code:
Dim connInfo As New Renci.SshNet.PasswordConnectionInfo(serverip, user, pass)
Dim sshClient As New Renci.SshNet.SshClient(connInfo)
Dim cmd As Renci.SshNet.SshCommand
Using sshClient
sshClient.Connect()
cmd = sshClient.RunCommand("opmnctl status -l")
MsgBox(cmd.Result)
sshClient.Disconnect()
End Using
While when I try with normal command like "ls -ltr"
it returns the result successfully.
Is there another way of fetching result string? Or are opmnctl
commands for OPMN Oracle engine not supported on Renci? Any help would be appreciated.
If the
opmnctl
fails for some reason, it might have produced a message on the error output.So check also
cmd.Error
andcmd.ExitStatus
.Note that the
.RunCommand
method uses a non-interactive terminal, what may cause problems with some commands.Particularly a different environment may be set, when the non-interactive terminal is used as a different set of startup scripts is executed and/or different branches in the scripts are taken (based on a value of a
TERM
environment variable).In your case, it seems that the
opmnctl
is not included inPATH
on non-interactive terminals.You should get the same issue when you force the non-interactive terminal in your SSH client.
For example:
With OpenSSH command-line
ssh
client, use-T
switch (Disable pseudo-tty allocation).The same with PLink (from PuTTY package)
(The
-T
should be implicit when command is specified on command-line anyway)Solution are:
opmnctl
toPATH
even on non-interactive terminals (preferred)opmnctl
in your command.SendPseudoTerminalRequest
request in.RunCommand
implementation (I didn't test this).