Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run a sudo script from "external tools" in IntelliJ / WebStorm / PhpStorm?

I would like my root-requiring bash script to be run from IntelliJ/WebStorm, asking me for the root password when I run it. Having my root password hardcoded in the script is a bad idea of course.

IntelliJ/WebStorm actually has a $Prompt$ macro for reasons like this, which prompts you and uses your input as a value.

So I tried using $Prompt$ along with echo YOURPASSWORD | sudo -S yourcommand as described in use-sudo-with-password-as-parameter.

Then I pass passwd & script to run to a sudorun.sh script echo -e $1 | sudo -S $2 $3 $4 (since echo can't be be the 'program' line) which although works on the CLI, it fails to read echo-stdin on the IntelliJ console.

Ideally, I would like the solution to be configured solely from within IntelliJ and not require specific OS configuration changes outside of IntelliJ.

Perhaps there are other ways to deal with this, so lets improvise!

like image 789
Angelos Pikoulas Avatar asked Oct 25 '12 21:10

Angelos Pikoulas


1 Answers

I, too, faced the same issue, but I work with sensitive data on my development machine and removing the password requirement for sudoers just isn't an option.

I was able to resolve this issue by launching the actual WebStorm application from the command line using the sudo command as follows:

sudo /Applications/WebStorm.app/Contents/MacOS/webide

Once WebStorm/PhpStorm are launched this way, you can run a script with root access without supplying root credentials.

like image 70
Mark Bonano Avatar answered Sep 18 '22 00:09

Mark Bonano