1

I am trying to achieve a functionality where I can open a new command prompt and run some batch commands. Then redirecting the output to a logfile and console on real time. So I am using wtee.exe (ex command: dir 2 >& 1 | wtee.exe logFile.txt). Choosing popen over os.system because I need control over the new process (new command prompt) As I wont be able to use pipe symbol in Popen. I did the below functionality newConsole = Popen( ['cmd','/V:ON /K dir 2>&1'], creationflags=CREATE_NEW_CONSOLE,stdout=PIPE,stderr=STDOUT ) outputLog = Popen( [wtee.exe,'logFile.txt'], stdin=newConsole.stdout, ) I can see the log file is generated and also the output in command prompt (on main window and not in new console). How can I print an output a new console opened using subprocess?

AlanAdams
  • 73
  • 1
  • Does this answer your question? [Python Popen: Write to stdout AND log file simultaneously](https://stackoverflow.com/questions/15535240/python-popen-write-to-stdout-and-log-file-simultaneously) – rdas Feb 03 '20 at 17:09

0 Answers0