I have one Java file named app.java
which extracts the servers in my application.
I need to connect to every server in that list and extract the logs. In loop, I have to call script for connecting to every machine. Is it possible to call shell script from java file ? Any suggestions please.
Here I am adding sample example:
for (int m = 0; m < AppDetailsN.length(); ++m)
{
JSONObject AppUsernIP=AppDetailsN.getJSONObject(m));
Iterator keys = AppUsernIP.keys();
while(keys.hasNext()) {
String key = (String)keys.next();
System.out.println("key:"+key);
String value = (String)AppUsernIP.get(key);
System.out.println("value "+value);
if(key == "user")
// Store value to user variable
// [..]
if (key == "ip")
//store value to IP variable
// [..]
}
//Here I want to call the script with that username and IP and password
}