paramiko / ssh / pythonを使用して、リモートサーバーでコマンドを実行しようとしています。手動でsshを実行し、問題のコマンドを実行すると、希望する結果が得られます。しかし、以下のpython(このサイトの別のスレッドから採用)を使用すると、返されるデータはありません。コマンドを「pwd」や「ls」などのより基本的なものに変更すると、出力を取得できます。どんな助けでも大歓迎です。
ありがとう、マット
import paramiko
import time
import sys, os, select
import select
hostname='10.15.27.166'
hostport=22
cmd='tail -f /x/web/mlog.txt' #works
#cmd='customexe -args1 -args2' #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)