Redirect output to jsh

Hi there!

I am working on a simple java shell in Windows XP at the moment which simply parses an entered command and passes it to ProcessBuilder as a list.

It works ok - the process startsas expected - the only problem is I cannot see any output from the processes, nor can I figure out a way to redirect STDOUT to the running java shell from XP (which is what I really want).

Here is my code so far - as I said, it's fairly basic at the moment.

publicclass shell{

publicvoid start()throws java.io.IOException{

String commandLine;

BufferedReader console =new BufferedReader

(new InputStreamReader(System.in));

while(true){

System.out.print("jsh>");

commandLine = console.readLine();

if(commandLine.equals(""))

continue;

else process(commandLine);

continue;

}

}

privatevoid process(String cmd)

{

String command = cmd;

String[] commsplit = command.split("\\s");

ProcessBuilder pb =new ProcessBuilder(Arrays.asList(commsplit));

try{

pb.start();

}

catch (IOException ioe){

System.err.println("Unknown command or input. Please try again");

}

}

publicstaticvoid main(String[] args)throws java.io.IOException{

shell shell1 =new shell();

shell1.start();

}

}

Any pointers in the right direction would be most appreciated.

[2671 byte] By [PBennetta] at [2007-11-27 0:49:21]
# 1
You need to process the stdout and stderr of the Process. This http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html shows you how to do it safely!
sabre150a at 2007-7-11 23:18:50 > top of Java-index,Java Essentials,New To Java...
# 2
Ahh brilliant!It's not that safe at the moment, but it's working.Thank you very much sabre!
PBennetta at 2007-7-11 23:18:50 > top of Java-index,Java Essentials,New To Java...