Advertisement
Guest User

Untitled

a guest
May 26th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. p = subprocess.Popen(args='test.bat'.split(), stdout=sp.PIPE, stdin=sp.PIPE, universal_newlines=True)
  2. p.stdin.write("n")
  3. p.stdin.flush()
  4. for line in p.stdout:
  5. print line
  6.  
  7. Are you sure you want to continue[Y/N]?
  8.  
  9. p = subprocess.Popen(args='test.bat'.split(), stdout=sp.PIPE, stdin=sp.PIPE, universal_newlines=True)
  10. for line in p.stdout:
  11. if line.startswith('Please type x/y"):
  12. p.stdin.write('x')
  13. p.stdin.flush()
  14. if line.startswith('please choose 1/2'):
  15. p.stdin.write('2')
  16. p.stdin.flush()
  17.  
  18. p = sp.Popen(args='try.bat'.split(), cwd=WORKING_DIRECTORY, shell=True, stdout=sp.PIPE, stdin=sp.PIPE, universal_newlines=True)
  19. while True:
  20. nextline = p.stdout.readline()
  21. if nextline.startswith("enter x/y"):
  22. p.stdin.write("y")
  23. p.stdin.flush()
  24. if nextline == '' and p.poll() is not None:
  25. break
  26. sys.stdout.write(nextline)
  27. sys.stdout.flush()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement