0

I am using a .NET library Renci.SshNet to connect to remote Solaris machine (its a VM on ESXi). It connects fine.

I use the following method to execute the commands and get the Standard Output. This works fine on any Linux machine and almost all command on Solaris (Except few - which is where the issue is)

outstring = sshClient.RunCommand(command).Execute();

For example when command = "cat /etc/release | grep Solaris" -it works fine. However, when command = "smbios -t SMB_TYPE_SYSTEM" - it doesn't return anything. I try redirecting it to a file. The file gets created - but doesn't have anything on it.

I connect to the system using PuTTY and run the command - it runs perfectly and gives the desired output.

I am perplexed by this behavior. I am using a username with root privilloginto logon. So privileges are ruled out (anyway the same user gets the output in PuTTY).

I am wondering if there is any setting or restriction on Solaris (I am running ver 11.3) which does not allow the smbios command to run like this over a remote connection? Or it is something else? Any guidance will be extremely helpful. If any further info is required, please let me know.

Kindle Q
  • 944
  • 2
  • 19
  • 28
anil
  • 598
  • 1
  • 6
  • 20
  • This is most likely a problem with Renci.SshNet not allocating a pseudoterminal for the remote command. See http://stackoverflow.com/questions/32367295/renci-ssh-net-no-result-string-returned-for-opmnctl The only reason it *may* not be a duplicate is the target OS is different. – Andrew Henle Sep 26 '16 at 10:02
  • Thanks Andrew for the response and pointing to the other question. Will check on the advice there as well. Also would check Renci Documentation on how to get a pseudoterminal allocated for RunCommand. – anil Sep 27 '16 at 07:20

1 Answers1

0

Well, it turns out that it was to do with Path settings. When you login through Putty the $PATH as defined gets set. Hence smbios runs from Putty.

But in a SSH session the $PATH environment variable does not get applied. So its not able to find smbios to run. If you give the full path of smbios - like /usr/sbin/smbios it executes fine over Renci.SshNet.

anil
  • 598
  • 1
  • 6
  • 20