Re: can't get Runtime.getRuntime().exec to work..
Sohaila Roberts <[email protected]> Fri, 23 Aug 2002 11:49:32 -0230
| Newsgroups | gmane.comp.windows.devel.java.general |
|---|---|
| Message-ID | <[email protected]> |
Thanks! even tho that article focused on windows ;) it helped, i was
lacking the 'bash' (i'm on unix) part of my command.. (or as the article
mentioned command.exe on windows..)
Thanks again.
Sohaila
On Fri, 23 Aug 2002, David Rosenstrauch wrote:
> Take a look at this article:
>
> http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html
>
> It should help you solve your problem.
>
>
> DR
>
>
> At 10:37 AM 8/23/2002 -02-30, you wrote:
> >Hi, I have the following code
> >
> > String tmp2 = "hmm";
> > String cmd1 = "html2ps -o "+tmp2+".ps "+tmp2+".html";
> > System.out.println("going to do "+cmd1);
> > Process p = Runtime.getRuntime().exec(cmd1);
> > BufferedReader stdInput = new BufferedReader(new
> > InputStreamReader(p.getInputStream()));
> > BufferedReader stdError = new BufferedReader(new
> > InputStreamReader(p.getErrorStream()));
> > // read the output from the command
> > String s;
> > System.out.println("Here is the standard output of the
> > command:\n");
> > while ((s = stdInput.readLine()) != null) {
> > System.out.println(s);
> > }
> > //wait for end of process and get exit status
> > int status ;
> > status = p.waitFor();
> > if (status != 0) {
> > System.out.println("The command returned a status of " +
> > status);
> > }
> >
> > // 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 (InterruptedException intexc) {
> > System.out.println("Interrupted Exception on waitFor: " +
> > intexc.getMessage());
> > } catch (IOException e) {
> > System.out.println("ExecuteCmd.main() : " + e);
> > } catch (Exception e) {
> > System.out.println("ExecuteCmd.main() : " + e);
> > }
> >
> >and I get the following output
> >
> >going to do html2ps -o hmm.ps hmm.html
> >Here is the standard output of the command:
> >
> >The command returned a status of -1
> >Here is the standard error of the command (if any):
> >
> >
> >hmm.ps doesnt get created and i get no errors.. but when i do that command
> >on the command shell it creates hmm.ps with no problem..
> >
> >any suggestions why?
> >
> >thanks
> >sohaila
>
> You can read messages from the JAVA archive, unsubscribe from JAVA,
> or subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
You can read messages from the JAVA archive, unsubscribe from JAVA,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.