0

I have the following code which runs good on a remote Unix server and completes the task through ssh.exec_command(). But, I want to store the log in a text file in my Windows PC from where it is being executed. How do I redirect the output of stdout_data and stderr_data to two different txt files which I can store as a future log?

#!/usr/bin/env/python

import paramiko

trans = paramiko.Transport(('fcd01.force.com',22))
trans.connect(username = 'user',password = 'pwd')
session = trans.open_channel("session")
session.exec_command('cd /project/fcd_neptune_psv/akar/neptune_psv/fw; ./Do_Regr.sh -i Testlist_Regression.in -m 135.24.237.167 -g')

stdout_data = []
stderr_data = []

while True:

    if session.recv_ready():
        stdout_data.append(session.recv(4096))

    if session.recv_stderr_ready():
        stderr_data.append(session.recv_stderr(4096))

    if session.exit_status_ready():
        break

print 'exit status: ', session.recv_exit_status()
print ''.join(stdout_data)
print ''.join(stderr_data)

session.close()
trans.close()
user3565150
  • 884
  • 5
  • 21
  • 49
  • possible duplicate of [After executing a command by Python Paramiko how could I save result?](http://stackoverflow.com/questions/8138241/after-executing-a-command-by-python-paramiko-how-could-i-save-result) – Ozgur Vatansever Feb 12 '15 at 07:21
  • how do I store stdout_data and stderr_data in two separate logs? – user3565150 Feb 12 '15 at 08:33

0 Answers0