title: Execute bash script from URL
body: <p>Say I have a file at the URL <code>http://mywebsite.example/myscript.txt</code> that contains a script:</p>
  <pre><code>#!/bin/bash
  echo &quot;Hello, world!&quot;
  read -p &quot;What is your name? &quot; name
  echo &quot;Hello, ${name}!&quot;
  </code></pre>
  <p>And I'd like to run this script without first saving it to a file. How do I do this?</p>
  <p>Now, I've seen the syntax:</p>
  <pre><code>bash &lt; &lt;(curl -s http://mywebsite.example/myscript.txt)
  </code></pre>
  <p>But this doesn't seem to work like it would if I saved to a file and then executed. For example readline doesn't work, and the output is just:</p>
  <pre><code>$ bash &lt; &lt;(curl -s http://mywebsite.example/myscript.txt)
  Hello, world!
  </code></pre>
  <p>Similarly, I've tried:</p>
  <pre><code>curl -s http://mywebsite.example/myscript.txt | bash -s --
  </code></pre>
  <p>With the same results.</p>
  <p>Originally I had a solution like:</p>
  <pre><code>timestamp=`date +%Y%m%d%H%M%S`
  curl -s http://mywebsite.example/myscript.txt -o /tmp/.myscript.${timestamp}.tmp
  bash /tmp/.myscript.${timestamp}.tmp
  rm -f /tmp/.myscript.${timestamp}.tmp
  </code></pre>
  <p>But this seems sloppy, and I'd like a more elegant solution.</p>
  <p>I'm aware of the security issues regarding running a shell script from a URL, but let's ignore all of that for right now.</p>