0
votes

I am deploying Hazelcast management center in a virtual lab to manage clusters within the same network.

In the documentation, I noticed the "Scripting" feature, allowing the admin to execute Javascript, Ruby, Groovy, or Python codes on the clusters.

But I cannot find much reference on what Javascript codes can be executed?

Is it possible to execute os commands on the clusters?

1

1 Answers

1
votes

Yes. It's possible to run OS commands from scripts.

You can access the Java objects (including java.lang.Runtime) from the script.

The Javascript uses JDK provided engine for instance - Rhino for Java 6-7, Nashorn for Java 8+.

Nashorn

https://docs.oracle.com/javase/9/scripting/using-java-scripts.htm#JSJSG116

Java.type("java.lang.Runtime").getRuntime().exec("touch test.txt");

Rhino

https://docs.oracle.com/javase/7/docs/technotes/guides/scripting/programmer_guide/#jstojava

importClass(java.lang.Runtime);
Runtime.getRuntime().exec("touch test.txt");