To read data from Putty and store it in another file by Python
<p>I need a script in Python that will collect the logs/information from PUTTY and then need to store this information in an another file saved in drive.</p>

<pre><code>import subprocess
import sys

HOST="127.0.0.1"
# Ports are handled in ~/.ssh/config since we use OpenSSH
COMMAND="uname -a"

ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],
                       shell=False,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.PIPE)
result = ssh.stdout.readlines()
if result == []:
    error = ssh.stderr.readlines()
    print &gt;&gt;sys.stderr, "ERROR: %s" % error
else:
    print result
</code></pre>

python