import java.io.*; import java.util.*; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here String s = null; try { String pmrFormulaFile = "/opt/ericsson/amos/moshell/commonjars/pm/FORMULA_RNC_H_1_0.txt"; String pmrConfigurationFileStr = "/opt/ericsson/amos/moshell/commonjars/pm/CONFIG_RNC_H_1_0.txt"; List lineList = new ArrayList(); lineList.add("pmr -l /home/" + "roisht" + "/" + "RNC028" + " -f " + pmrFormulaFile + " -c " + pmrConfigurationFileStr + " -m " + "4"); Process p = Runtime.getRuntime().exec("moshell"); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); BufferedWriter stdOutput = new BufferedWriter(new OutputStreamWriter(p.getOutputStream())); stdOutput.write(lineList.get(0)); stdOutput.newLine(); stdOutput.flush(); lineList.add("17"); stdOutput.write(lineList.get(1)); stdOutput.newLine(); stdOutput.flush(); lineList.add("18"); stdOutput.write(lineList.get(2)); stdOutput.newLine(); stdOutput.flush(); // read the output from the command System.out.println("Here is the standard output of the command:\n"); while ((s = stdInput.readLine()) != null) { System.out.println(s); } // read any errors from the attempted command System.out.println("Here is the standard error of the command (if any):\n"); while ((s = stdError.readLine()) != null) { System.out.println(s); } // In this part the program stucked lineList.add("18"); stdOutput.write(lineList.get(2)); stdOutput.newLine(); stdOutput.flush(); // read the output from the command System.out.println("Here is the standard output of the command:\n"); while ((s = stdInput.readLine()) != null) { System.out.println(s); } // read any errors from the attempted command System.out.println("Here is the standard error of the command (if any):\n"); while ((s = stdError.readLine()) != null) { System.out.println(s); } } catch (IOException e) { System.out.println("exception happened - here's what I know: "); e.printStackTrace(); System.exit(-1); } } }