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.

