Renci SSH.NET-没有为opmnctl返回结果字符串
我试图通过VB.NET从命令中获取结果,它返回空字符串,如下代码所示:Renci SSH.NET-没有为opmnctl返回结果字符串,.net,vb.net,oracle,ssh,ssh.net,.net,Vb.net,Oracle,Ssh,Ssh.net,我试图通过VB.NET从命令中获取结果,它返回空字符串,如下代码所示: 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() c
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”
时,它会成功返回结果
是否有其他获取结果字符串的方法?或者Renci上不支持OPMN-Oracle引擎的
opmnctl
命令?任何帮助都将不胜感激。如果opmnctl
由于某种原因失败,它可能会在错误输出上产生一条消息
因此,还要检查cmd.Error
和cmd.ExitStatus
请注意,
.RunCommand
方法使用非交互式终端,这可能会导致某些命令出现问题
特别地,当非交互终端被用作执行不同的启动脚本集和/或脚本中的不同分支(基于术语环境变量的值)时,可以设置不同的环境
在您的情况下,在非交互式终端上,optmctl
似乎不包括在PATH
中
在SSH客户机中强制使用非交互式终端时,应该会遇到同样的问题
例如:
- 使用OpenSSH命令行
ssh
客户端,使用-T
开关(禁用伪tty分配)
- 与PLink相同(来自腻子包装)
(无论如何,当在命令行上指定命令时,-T
应该是隐式的)
解决方案是:
- 修复启动脚本,使其包括
optmnctl
至路径
,即使在非交互式终端上也是如此(首选)
- 在命令中使用指向
opmnctl
的完整路径
- 修改SSH.NET代码以在
.RunCommand
实现中发出sendpeudoterminalrequest
请求(我没有测试这个)
ssh -T user@host opmnctl status -l
plink.exe -T user@host opmnctl status -l