Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p = subprocess.Popen(args='test.bat'.split(), stdout=sp.PIPE, stdin=sp.PIPE, universal_newlines=True)
- p.stdin.write("n")
- p.stdin.flush()
- for line in p.stdout:
- print line
- Are you sure you want to continue[Y/N]?
- p = subprocess.Popen(args='test.bat'.split(), stdout=sp.PIPE, stdin=sp.PIPE, universal_newlines=True)
- for line in p.stdout:
- if line.startswith('Please type x/y"):
- p.stdin.write('x')
- p.stdin.flush()
- if line.startswith('please choose 1/2'):
- p.stdin.write('2')
- p.stdin.flush()
- p = sp.Popen(args='try.bat'.split(), cwd=WORKING_DIRECTORY, shell=True, stdout=sp.PIPE, stdin=sp.PIPE, universal_newlines=True)
- while True:
- nextline = p.stdout.readline()
- if nextline.startswith("enter x/y"):
- p.stdin.write("y")
- p.stdin.flush()
- if nextline == '' and p.poll() is not None:
- break
- sys.stdout.write(nextline)
- sys.stdout.flush()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement