how am I hosing this Process?

Thomas L Roche <tlroche-r/[email protected]>
Newsgroups gmane.org.user-groups.trijug.juglist
Message-ID <OFFC05B84C.DA97A4D5-ON87257281.000FEC8B-85257281.00110B73@us.ibm.com>
I'm trying to run a bash script from Java in order to run it under
JUnitPerf, but am failing miserably. Any suggestions about what I'm
missing? except chops :-(

I've called scripts from Java before, but not for awhile (i.e. back in
the Runtime.exec days). Process/Builder looked like the way to go, so
I coded up something like

  public static void execute(List<String> l) throws RunnerException {
    Process p = null;
    ProcessBuilder pb = new ProcessBuilder(l);
    String argsMsg = "\"" + Utils.list2String(l) + "\"";
    // start debugging
    Utils.logInfo("start output from " + argsMsg + ":");
    Utils.logEnvironment(pb);
    // end debugging
    try {
      p = pb.start();
    } catch (IOException e) {
      String errmsg = "Failed to run command=" + argsMsg;
      throw new RunnerException(errmsg, e);
    }
    InputStream is = p.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line;
    try {
      while ((line = br.readLine()) != null) {
        Utils.logInfo(line);
      }
    } catch (IOException e) {
      String errmsg = "Dropped output line from process";
      throw new RunnerException(errmsg, e);
    }
    // start debugging
    Utils.logInfo("end output from " + argsMsg);
    // end debugging
  }

but nothing's happening ... except the logging above. From that I can
tell that I'm calling the correct command line (i.e. argsMsg has the
expected value, with a fully-qualified executable and all the
arguments) and I've got a correct environment. But when I call the
command from an xterm (FWIW I'm running on linux) Stuff Actually
Happens (notably files get created in a directory, and a whole lot
more logging happens); when I call the java app, nothing actually
happens except the logging above. I.e. I get

- start output from "<correct commandline/>":
- start environment:
<correct environment/>
- end environment.
- end output from "<correct commandline/>"

when I should instead get

+ start output from "<correct commandline/>":
+ start environment:
<correct environment/>
+ end environment.
<LOTS MORE STUFF HERE/>
+ end output from "<correct commandline/>"

plus lots of files in the output directory.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.