Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, select, signal, subprocess, sys
- CMD = 'tail -f /var/log/syslog'
- def signal_cleanup(_signum, _frame):
- print '\nCLEANUP\n'
- sys.exit(0)
- def main():
- hosts = ['localhost', 'localhost']
- # exit after a few seconds
- signal.signal(signal.SIGALRM, signal_cleanup)
- signal.alarm(10)
- procs = [
- subprocess.Popen(
- 'ssh {} {}'.format(host, CMD),
- shell=True,
- stdout=subprocess.PIPE,
- )
- for host in hosts
- ]
- while True:
- inputs,_outputs,_excepts = select.select(
- [p.stdout for p in procs], [], [],
- )
- for fd in inputs:
- print fd.readline(),
- print 'done!'
- if __name__=='__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement