Sunday, 18 August 2013

Python : paramiko ssh : ( 'cd / && ls ' ) works while ( ' yum install httpd ' ) does not

Python : paramiko ssh : ( 'cd / && ls ' ) works while ( ' yum install
httpd ' ) does not

I am trying to create a python script that will connect to a server and
install httpd.
here's my script so far.
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('************', username='root', password='************')
stdin, stdout, stderr = ssh.exec_command("cd / && ls")
a = stdout.readlines()
print a
the output is
['bin\n', 'boot\n', 'dev\n', 'etc\n', 'home\n', 'lib\n', 'lib64\n',
'lost+found\n', 'media\n', 'mnt\n', 'opt\n', 'proc\n', 'root\n', 'sbin\n',
'selinux\n', 'srv\n', 'sys\n', 'tmp\n', 'usr\n', 'var\n']
now let's try it with :
stdin, stdout, stderr = ssh.exec_command("yum install httpd")
a = stdout.readlines()
print a
this time there is nothing.
the script simply hangs up like this.
[root@oooo ~]# python aaa.py
in the terminal

No comments:

Post a Comment