Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- if sys.platform == 'win32':
- import winpexpect
- elif sys.platform == 'linux' or sys.platform == 'linux32':
- import pexpect
- from multiprocessing import Process, Queue
- def puthello(q):
- if sys.platform == 'win32':
- child = winpexpect.winspawn('cmd', timeout=9000)
- elif sys.platform == 'linux' or sys.platform == 'linux32':
- child = pexpect.spawn('bash', timeout=9000)
- while True:
- child.sendline('echo hello')
- child.expect('\r\n')
- q.put(child.before+child.after)
- q = Queue()
- p = Process(target=puthello, args=(q,))
- def launchprocess():
- p.start()
- while True:
- print q.get()
- if __name__ == '__main__':
- launchprocess()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement