Renci SSH.NET-opmnctl没有返回结果字符串 [英] Renci SSH.NET - no result string returned for opmnctl

查看:244
本文介绍了Renci SSH.NET-opmnctl没有返回结果字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过VB.NET从命令中获取结果,它返回空字符串,如下面的代码所示:

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

当我尝试使用"ls -ltr"之类的普通命令时,它会成功返回结果.

While when I try with normal command like "ls -ltr" it returns the result successfully.

还有另一种获取结果字符串的方法吗?还是Renci不支持OPMN Oracle引擎的opmnctl命令?任何帮助将不胜感激.

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.

推荐答案

如果opmnctl由于某种原因失败,则可能在错误输出中产生了一条消息.

If the opmnctl fails for some reason, it might have produced a message on the error output.

所以还要检查cmd.Errorcmd.ExitStatus.

请注意,.RunCommand方法使用非交互式终端,这可能会导致某些命令出现问题.

Note that the .RunCommand method uses a non-interactive terminal, what may cause problems with some commands.

当非交互式终端用作不同的启动脚本集和/或在脚本中采用不同的分支时(根据TERM环境变量的值),可以特别设置不同的环境).

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).

对于您而言,非交互式终端上的PATH中似乎没有包含opmnctl.

In your case, it seems that the opmnctl is not included in PATH on non-interactive terminals.

在SSH客户端中强制使用非交互式终端时,您应该遇到相同的问题.

You should get the same issue when you force the non-interactive terminal in your SSH client.

例如:

  • 对于OpenSSH命令行ssh客户端,请使用-T开关(禁用伪tty分配).

  • With OpenSSH command-line ssh client, use -T switch (Disable pseudo-tty allocation).

ssh -T user@host opmnctl status -l

  • 与PLink相同(来自PuTTY软件包)

  • The same with PLink (from PuTTY package)

    plink.exe -T user@host opmnctl status -l
    

  • (无论如何在命令行上指定命令时,-T应该是隐式的)

    (The -T should be implicit when command is specified on command-line anyway)

    解决方案是:

    • 修复启动脚本,即使在非交互式终端(首选)上也包含opmnctlPATH
    • 在命令中使用opmnctl的完整路径.
    • 修改SSH.NET代码以在.RunCommand实现中发出SendPseudoTerminalRequest请求(我没有对此进行测试).
    • Fix your startup scripts to include the opmnctl to PATH even on non-interactive terminals (preferred)
    • Use a full path to opmnctl in your command.
    • Modify SSH.NET code to issue SendPseudoTerminalRequest request in .RunCommand implementation (I didn't test this).

    这篇关于Renci SSH.NET-opmnctl没有返回结果字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆