You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
886 B
Java

import java.io.*;
public class ABasicShell
{
public static void main(String[] args) throws java.io.IOException {
String commandLine;
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
// we break out with <control><C>
while (true) {
// read what they entered
System.out.print("prompt>");
commandLine = console.readLine();
// if they entered a return, just loop again
if (!commandLine.equals("")){
AProcess aProcess = new AProcess();
String[] mycommands = commandLine.split(" ");
aProcess.main(mycommands);
} else{
continue;
}
/**
The basic steps are:
(1) parse the input to obtain the command
and any parameters
(2) create a ProcessBuilder object
(3) start the process
(4) obtain the output stream
(5) output the contents returned by the command
*/
}
}
}