I have a CLI binary that I would like to control through Python. How could this easily be done? I have tried making a terminal in a subprocess and opening it that way but that didn't work. I also thought about using keyboard emulation but that would be unreliable imo. More specifically, I want to use Stockfish's CLI through Python. The "I have tried making a terminal in a subprocess[...]" part refers to me trying to do that but being too unknowledgeable to actually achieve something. minimal reproducible example: import subprocess My_Cmmnd = "cd" process = subprocess.Popen( "powershell -e 'bash -c \"" + My_Cmmnd + ";bash\"'", stdout=subprocess.PIPE, stderr=None, shell=True, ) As you can probably tell, this doesn't work. I've also tried: import os os.system("cd path/to/stockfish") os.system("cd") This returns C:\path\to\project and not C:\path\to\stockfish as I would've expected. I am open to any method, and am not saying I have to do this this specific way. It was proposed that this may be similar to my question. In essence it is, but its outdated has no verified solution when i try to use cd, it cannot change directory as it cannot find it for some reason import subprocess command = subprocess.Popen(['cd C:\\path\\to\\stockfish'], shell=True) output: The filename, directory name, or volume label syntax is incorrect. I pasted it into cmd and it worked just fine. Continue reading...