Renci SSH.NET - no result string returned for opmnctl

前端 未结 1 383
一向
一向 2021-01-17 05:59

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


        
相关标签:
1条回答
  • 2021-01-17 06:31

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

    So check also cmd.Error and cmd.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 in PATH 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).

      ssh -T user@host opmnctl status -l
      
    • The same with PLink (from PuTTY package)

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

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


    Solution are:

    • 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).
    0 讨论(0)
提交回复
热议问题