not getting output from parmiko/ssh command

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-06-15T21:19:06Z Indexed on 2010/06/15 21:22 UTC
Read the original article Hit count: 310

Filed under:
|
|

I am using paramiko/ssh/python to attempt to run a command on a remote server. When I ssh manually and run the command in question, I get the results I want. But if I use the python (co-opted from another thread on this site) below, there is no returned data. If I modify the command to be something more basic like 'pwd' or 'ls' I can then get the output. Any help is appreciated.

Thanks, Matt

import paramiko import time import sys, os, select import select username='medelman' password='Ru5h21iz' hostname='10.15.27.166' hostport=22 cmd='tail -f /x/web/mlog.txt' #works

cmd='' #doesn't work

client = paramiko.SSHClient() client.load_system_host_keys() client.connect(hostname=hostname, username=username, password=password) transport = client.get_transport() channel = transport.open_session() channel.exec_command(cmd) while True: rl, wl, xl = select.select([channel],[],[],0.0) if len(rl) > 0: # Must be stdout print channel.recv(1024) time.sleep(1)

© Stack Overflow or respective owner

Related posts about python

Related posts about ssh