Re: how am I hosing this Process?
"Robert Dale" <[email protected]>
| Newsgroups | gmane.org.user-groups.trijug.juglist |
|---|---|
| Message-ID | <[email protected]> |
I would definitely check the error stream. It may be that the command you are calling requires a tty. On 2/12/07, Thomas L Roche <tlroche-r/[email protected]> wrote: > 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. > > > _______________________________________________ > Juglist mailing list > [email protected] > http://trijug.org/mailman/listinfo/juglist_trijug.org > -- Robert Dale