I would like to output some data in a separated console window on windows.
Therefore I start a new subprocess calling ‘cmd’ to open a new window and start writing via the stdin.write() method:
import subprocess
import time
cli_ampel_proc = subprocess.Popen(['cmd'], stdin=subprocess.PIPE, creationflags=subprocess.CREATE_NEW_CONSOLE, text=True)
cli_ampel_proc.stdin.write('@echo offn')
cli_ampel_proc.stdin.flush()
cli_ampel_proc.stdin.write('clsn') # Clear the console
cli_ampel_proc.stdin.write('echo Startn')
cli_ampel_proc.stdin.flush()
time.sleep(3)
What I would like to have is a clean output just showing:
Start
However I get this:
echo Start
Start
How can I suppress the first line (echo Start
)?