How to run shell script in the plugin Follow
I have a need to run a shell script in the plugin , and I write the code like
public class ScriptRunner {
public static void run(String script){
try {
Process process = Runtime.getRuntime().exec(new String[]{"/bin/sh", "-c", script});
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "\n running script : " + script + "\n";
String currentLine;
while ((currentLine = br.readLine()) != null) {
line += currentLine + "\n";
}
PluginManager.getLogger().error(line);
process.waitFor();
} catch (Throwable e) {
PluginManager.getLogger().error(e);
}
}
}
In the SandBox , it worked well , logger showed the whole executing process
But after plugin deployment, it did not execute the script . And I got nothing from the log which logger logged.
The script is like
lark2gitbook -t "xxxxxxxxxxx" -s xxxxxxx -o xxxxxx --public
My os is Mac os 10.13.5
Idea version is '2018.2' 'Ultimate'
So, why did it not work in normal environment , and how can I fix it.
Thanks a lot
Please sign in to leave a comment.
>But after plugin deployment, it did not execute the script .
I mean "In normal environment ,I used the plugin , but it did not execute the script" but not "It did not execute the script during plugin deployment"