title: How to send EOF using scala process utility
body: <p>I want to start a python program from inside a scala program that has to receive a possibly infinitely long string. Thus it is not possible to pass it as a cmd argument.</p>
  <p>My solution is to transmit the data via the stdstreams. However, I am unable to find the scala version of the working bash code:</p>
  <p>bash code:</p>
  <pre><code>#/bin/bash
  var=&quot;SOME REALLY LONG STRING THAT IS SEND TO THE PYTHON PROGRAM&quot;
  echo &quot;$var&quot; | ./readUntilEOF.py
  </code></pre>
  <p>scala code:</p>
  <pre><code>import sys.process._
   
  object main {
  
         def main(args : Array[String]) : Unit = {
             val cmd = &quot;./readUntilEOF.py&quot;
             val string = &quot;SOME REALLY LONG STRING THAT IS SEND TO THE PYTHON PROGRAM&quot;
             print(&quot;I am starting to send stuff...&quot;)
             val resultString = (string #| cmd.!!).!!
             print(resultString)
         }
   
  }
  </code></pre>
  <p>readUntilEOF.py:</p>
  <pre><code>#!/usr/bin/python3
  
  import sys
  
  if __name__ == &quot;__main__&quot;:
      read = sys.stdin.read()
      print(read)
  </code></pre>
  <p>Output running the bash command:</p>
  <pre><code>#&gt; ./scalaBashEquivalent.sh 
  SOME REALLY LONG STRING THAT IS SEND TO THE PYTHON PROGRAM
  
  
  </code></pre>
  <p>Output running the scala code:</p>
  <pre><code>#&gt; scala scala.sc
  I am starting to send stuff...
  /* and then it never terminates */
  </code></pre>