Receiving streaming output from ssh connection in Python -
i running script remotely on server via ssh , python. script looks through log files , returns information based on each log entry encounters. problem running although script spits out information hits each log entry, local machine needs wait entire process finish before can read lines ssh connection's stdout.
ssh = subprocess.popen(cmd.split(' '), stdout=subprocess.pipe) open(remote_ip+'.hits', 'w') f: line in ssh.stdout: print line
essentially code prints of results @ once, @ end. wondering if there way me print out contents of stdout being produced on server. sorry if unclear, if ambiguous best clarify it. thanks!
edit: should add preferably without external packages, built-in modules 2.6 if possible.
Comments
Post a Comment