//ConsoleWindow.java import java.io.*; public class shell extends VMachine { String shhname; boolean initialrun; String initialworker; public shell () {// Used when new instance created } public shell (String name, String worker) {// Used when creating a shell and executing a worker // Also used for initial startup shhname = name; initialworker = worker; initialrun = true; } public shell (String name) {// Used when creating new shell ConsoleWindow console = new ConsoleWindow(name); } public void run () { try { sysapi.Write(OUT,"% "); String str = sysapi.Read(IN); String exitstr = str.toLowerCase(); Parser line = new Parser(); Command dennis = new Command(); // dennis.init(); while(exitstr.compareTo("exit") != 0)//console.Active()) { CommandArray inputLine = new CommandArray(); try { inputLine = line.Parse(str); } catch (Exception e) {} try { // dennis = inputLine.Commands[0]; // int i=0; // while (dennis.command != null) // { // sysapi.Write(OUT, inputLine.count+" command: "+dennis.command+"\n"); // if (dennis.args[0] != null) // { // int temp = 0; // sysapi.Write(OUT, "argcount: "+dennis.argcount+"\n"); // while (dennis.args[temp] != null){ // sysapi.Write(OUT, "arg: "+dennis.args[temp]+"\n"); // temp++; // } // } // if (dennis.in_flag != 0) // { sysapi.Write(OUT, "input redirection: "+dennis.input+"\n"); } // if (dennis.out_flag != 0) // { sysapi.Write(OUT, "output redirection: "+dennis.output+"\n"); } // // execute(dennis); if(sysapi.findUser(owner).isClosing) { break; } // i++; // dennis = inputLine.Commands[i]; // }//end while dennis }//end try catch (Exception e){ // sysapi.Write(OUT,"Command not recognized or not found.\n"); }//catch execute(inputLine); sysapi.Write(OUT,"% "); str = sysapi.Read(IN); exitstr = str.toLowerCase(); }//while not exit sysapi.Exit(vmh,owner); }//try catch (Exception e) {} //console.dispose(); //console.Always_Wait_For_Finish(); //System.exit(0); }//run public void execute(CommandArray inputLine) //Command dennis) //String strworker) { // try { sysapi.Write(OUT,"command size: " + inputLine.count + "\n"); } // catch (Exception e) {} FileClassLoader fileclass = null; fileclass = new FileClassLoader(); fileclass.bindir = "C:\\java\\OSVM\\bin\\"; Class newclass = null; int argstart; int i=0; Command dennis = new Command(); dennis = inputLine.Commands[0]; while (i < inputLine.count) { // try { sysapi.Write(OUT,"command in loop: " + dennis.command + "\n"); } // catch (Exception e) {} VMachine vm1 = null; Handle current_in; Handle current_out; if (dennis.in_flag != 0) { current_in = sysapi.OpenFile(dennis.input); } else { current_in = IN; } if (dennis.out_flag != 0) { current_out = sysapi.OpenFile(dennis.output); } else { current_out = OUT; } // try { sysapi.Write(OUT,"command " + i + " in loop: " + dennis.command + "\n"); } // catch (Exception e) {} String[] cmdargs = new String[dennis.argcount]; // Arguments Passed to Workers int tempargcount = 0; for (tempargcount = 0; tempargcount < dennis.argcount; tempargcount++) { cmdargs[tempargcount] = dennis.args[tempargcount]; } try { newclass = fileclass.loadCmd(dennis.command); //strworker); } catch(Exception ex) { try { sysapi.Write(OUT,"Command not recognized or not found.\n"); } catch (Exception e) {} } try { Handle vmh1 = sysapi.CreateVM(current_in,current_out,newclass,owner,cmdargs,this,null,0); sysapi.findUser(owner).addHandle(vmh1); } catch(Exception e) { // try { sysapi.Write(OUT,"Program could not execute.\n"); } // catch (Exception ex) {} } // try { sysapi.Write(OUT,"again command: " + dennis.command + "\n"); } // catch (Exception e) {} i++; dennis = inputLine.Commands[i]; }//end while sysapi.Compute(vmh); // try { sysapi.Write(OUT,"out of loop\n"); } // catch (Exception e) {} // return; }//end execute };