title: How can I run a sudo script from "external tools" in IntelliJ / WebStorm / PhpStorm?
body: <p>I would like my <em>root-requiring</em> bash script to be run from <strong>IntelliJ/WebStorm</strong>, asking me for the root password when I run it. Having my root password hardcoded in the script is a bad idea of course.</p>
  
  <p><strong>IntelliJ/WebStorm</strong> actually has a $Prompt$ macro for reasons like this, which prompts you and  uses your input as a value.</p>
  
  <p>So I tried using <em>$Prompt$</em> along with <em><code>echo YOURPASSWORD | sudo -S yourcommand</code></em> as described in <a href="https://stackoverflow.com/questions/11955298/use-sudo-with-password-as-parameter">use-sudo-with-password-as-parameter</a>.</p>
  
  <p>Then I pass passwd &amp; script to run to a <code>sudorun.sh</code> script <code>echo -e $1 | sudo -S $2 $3 $4</code> (since <code>echo</code> can't be be the 'program' line) which although works on the CLI, it fails to read  echo-stdin  on the IntelliJ console.</p>
  
  <p>Ideally, I would like the solution to be configured solely from within IntelliJ and not require specific OS configuration changes outside of IntelliJ.</p>
  
  <p>Perhaps there are other ways to deal with this, so lets improvise!</p>