title: How can I use Python to interact with the Ubuntu terminal for windows 10?
body: <p>I am running compiled c code on the Ubuntu subsystem for Windows. I would like to automate this process with a Python script that can open the terminal, send and read commands as well as closing the window. </p>
  
  <p>I am trying this on Python 3.6 in Windows 10. I thought it was going to be the same as interfacing Python with the CMD but all the things I try are not yielding results. I want to know if anyone has tried to automate processes with the Ubuntu subsystem for Windows and how can that be achieved.
  First, I had to find the .exe that launches the Ubuntu app, since it's downloaded from the microsoft store. </p>
  
  <p>Using OS simply gives me the following result without opening the terminal.</p>
  
  <pre class="lang-py prettyprint-override"><code>import os
  os.system(r"C:\Program Files\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_1804.2019.521.0_x64__79rhkp1fndgsc\Ubuntu.exe")
  </code></pre>
  
  <p><code>1</code></p>
  
  <p>Also using subprocess will open the terminal. But parting from there, how can I give it commands and read the outputs?</p>
  
  <pre class="lang-py prettyprint-override"><code>import subprocess
  subprocess.Popen([r"C:\Program Files\WindowsApps\CanonicalGroupLimited.UbuntuonWindows_1804.2019.521.0_x64__79rhkp1fndgsc\Ubuntu.exe"])
  </code></pre>