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)