title: Difference between piping a file to sh and calling a shell file
body: <p>This is what was trying to do:</p>
  
  <pre><code>$ wget -qO- www.example.com/script.sh | sh
  </code></pre>
  
  <p>which quietly downloads the script and prints it to stdout which is then piped to sh. This unfortunately doesn't quite work, failing to wait for user input at various points, aswell as a few syntax errors.</p>
  
  <p>This is what actually works:</p>
  
  <pre><code>$ wget -qOscript www.example.com/script.sh &amp;&amp; chmod +x ./script &amp;&amp; ./script
  </code></pre>
  
  <p>But what's the difference?</p>
  
  <p>I'm thinking maybe piping the file doesn't execute the file, but rather executes each line individually, but I'm new to this kind of thing so I don't know.</p>