title: Running executable files using Haskell
body: <p>Say there's a C++ code that I've compiled into an executable using:</p>
  
  <pre><code>g++ test.cpp -o testcpp
  </code></pre>
  
  <p>I can run this using Terminal (I'm using OS X), and provide an input file for processing inside the C++ program, like:</p>
  
  <pre><code>./testcpp &lt; input.txt
  </code></pre>
  
  <p>I was wondering if doing this is possible, from <em>within</em> Haskell. I have heard about the <code>readProcess</code> function in <code>System.Process</code> module. But that only allows for running system shell commands.</p>
  
  <p>Doing this:</p>
  
  <pre><code>out &lt;- readProcess "testcpp" [] "test.in"
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>out &lt;- readProcess "testcpp &lt; test.in" [] ""
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>out &lt;- readProcess "./testcpp &lt; test.in" [] ""
  </code></pre>
  
  <p>throws out this error (or something very similar depending on which one of the above I use):</p>
  
  <pre><code>testcpp: readProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
  </code></pre>
  
  <p>So my question is, whether doing this is possible from Haskell. If so, how and which modules/functions should I use? Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Ok, so as David suggested, I removed the input arguments and tried running it. Doing this worked:</p>
  
  <pre><code>out &lt;- readProcess "./testcpp" [] ""
  </code></pre>
  
  <p>But I'm still stuck with providing the input.</p>