AMADEUS html plain
This sketchy text is generated by AMADEUS
import java.util.*;
import java.io.*;
class Exec
public class Exec
Autor: Lauri Kimmel
public String osName;
public Exec(String osName)
public String execCommand(String[] args)
String result = "";
..try
!!
String[] cmd = new String[3];
LINUX:
cmd[0] = "/bin/sh" ;
cmd[1] = "-c" ;
cmd[2]= CommandLine.arrayToString(args).trim();
***
result = "Execing '" + CommandLine.arrayToString(cmd) +"'";
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd);
***
protsessi lõpu ootamine. Sai ettepoole tõstetud 05.02.2010
int exitVal = proc.waitFor();
errorite lugeja
StreamGobbler errorGobbler =
new StreamGobbler(proc.getErrorStream(), "ERROR");
väljundi lugeja
StreamGobbler outputGobbler =
new StreamGobbler(proc.getInputStream(), "OUTPUT");
errorGobbler.start();
outputGobbler.start();
..while
* ;!(errorGobbler.isReady() && outputGobbler.isReady());
// läks ettepoole
protsessi lõpu ootamine
int exitVal = proc.waitFor();
result += errorGobbler.getResult() + outputGobbler.getResult()
+ "\n\nExitValue: " + exitVal + "\n";
..catch
! (Exception e)
result += "\nTrouble in Exec@execCommand: " + e;
System.out.println("CommandLine:Exec:catchMessage="+e);
<======result