0

I'd like to get the wget output at the same time or some seconds after it's printed on the terminal. To explain what I'm trying to get look at this command wget --recursive --no-clobber --page-requisites --html-extension --convert-links --no-parent http://programmers.blogoverflow.com/ it'll download this entire website, and during it's execution it'll output step by step the process it completed, this is what I'm trying to get. Do you guys know how can I do that?

This is what I have so far:

try {
    Process processWhoAmI = Runtime.getRuntime().exec("wget --recursive --no-clobber --page-requisites --html-extension --convert-links --no-parent http://programmers.blogoverflow.com/");
} catch (IOException e) {
    System.out.println(e);
}
Zignd
  • 6,896
  • 12
  • 40
  • 62
  • Are you doing this from a terminal or does it have to be from within a program. If it's from a terminal, look at I/O redirection in the bash manual page. – Jim Nutt Jun 13 '13 at 00:18
  • @JimNutt It have to be from within a program. :) – Zignd Jun 13 '13 at 00:19

1 Answers1

1

Start by taking a look at ProcessBuilder, it will save you a lot of hassles when it comes to generating processes.

Basically, you need to get the processes's InputStream and read it. This is connected to the processe's standard out.

You can use ProcessBuilder to redirect standard error through this stream as well, which will make life a lot easier...

And some examples...

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366