2

I'm writting a Software to get some Information about Server and i just want to get the python Version from an remote Server.

Here is my code:

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.server, username=self.user, password=self.pass)
stdin, stdout, stderr = ssh.exec_command("/usr/bin/python -V")
stdin.flush()
data = stdout.readlines()
print data  #just debug
ssh.close()

The print just returns "[]".

Hackbard
  • 440
  • 1
  • 4
  • 19

1 Answers1

3

It's in stderr. Don't ask me why:

>>> import paramiko
>>> ssh = paramiko.SSHClient()
>>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> ssh.connect('tek')
>>> stdin, stdout, stderr = ssh.exec_command('python --version')
>>> stdin.flush()
>>> data = stdout.readlines()
>>> data
[]
>>> data = stderr.readlines()
>>> data
['Python 2.6.6\n']
jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107
  • 2
    I told you not to ask me that! :^) seriously, it's probably just what Guido decided was appropriate. going to sleep now, hopefully any other questions will be answered by others. – jcomeau_ictx Jan 24 '12 at 09:44
  • 1
    Link to another SO question: [Why does python print version info to stderr?](https://stackoverflow.com/questions/26028416/why-does-python-print-version-info-to-stderr) – bitdancer Jan 24 '20 at 22:12