简体   繁体   English

以root身份从IntelliJ运行bash脚本

[英]Run bash script from IntelliJ as root

I have a bash script which needs root privileges. 我有一个需要root权限的bash脚本。 I run it by sudo ./script.sh . 我用sudo ./script.sh运行它。

I would like to create run configuration in IntelliJ IDEA, that runs this script with root privileges. 我想在IntelliJ IDEA中创建运行配置,它以root权限运行此脚本。 It doesn't matter if it asks for password later. 如果以后要求输入密码并不重要。

Is it possible without running IDE as root or using tools like gksudo or gksu ? 是否可以不以root身份运行IDE或使用gksudogksu等工具?

It was not super clear what Bash integration you use. 你使用什么Bash集成并不是很清楚。 Probably something like the plugin: BashSupport 可能类似于插件:BashSupport

https://plugins.jetbrains.com/plugin/4230-bashsupport https://plugins.jetbrains.com/plugin/4230-bashsupport

The runtime configuration window for this plugin seems not to expose permission configuration. 此插件的运行时配置窗口似乎不公开权限配置。

Hence, a simple pragmatic solution could be to actually write two scripts. 因此,一个简单的实用解决方案可能是实际编写两个脚本。

  1. You keep your script as it is 你保持脚本不变
  2. Create a second one that calls your current one with sudo 创建第二个用sudo调用当前的一个

sudo ./myscript.sh

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM