title: Ruby one-line script execution returns an error (on Windows)
body: <p>EDIT: I found an identical question that has been answered: <a href="https://stackoverflow.com/questions/12644837/how-can-i-escape-the-vertical-bar-when-doing-command-line-with-ruby">How can I escape the vertical bar when doing command line with Ruby</a></p>
  
  <p>I have <code>my.rb</code> file containing only one line:</p>
  
  <pre><code>File.popen("myprocess.exe","w"){|file| file.puts "help"; file.puts "quit";}
  </code></pre>
  
  <p>that I can execute via <code>ruby my.rb</code> and it works like a charm. However, if I try to run the following command:</p>
  
  <pre><code>ruby -e 'File.popen("myprocess.exe","w"){|file| file.puts "help"; file.puts "quit";}'
  </code></pre>
  
  <p>it complains that <em>"file" is not recognized as an internal or external command, operable program or batch file</em>. Trying to simplify it further, the following line still returns the error:</p>
  
  <pre><code>ruby -e 'File.popen("myprocess.exe","w"){|file|}'
  </code></pre>
  
  <p>And this code works fine:</p>
  
  <pre><code>ruby -e 'File.popen("myprocess.exe","w"){}'
  </code></pre>
  
  <p>What am I doing wrong? :(</p>