Package org.crsh.shell

Examples of org.crsh.shell.ShellProcess


            session.send("prompt", session.shell.getPrompt());
          } else if (type.getAsString().equals("execute")) {
            String command = event.get("command").getAsString();
            int width = event.get("width").getAsInt();
            int height = event.get("height").getAsInt();
            ShellProcess process = session.shell.createProcess(command);
            WSProcessContext context = new WSProcessContext(session, process, command, width, height);
            if (session.current.getAndSet(context) == null) {
              log.fine("Executing \"" + command + "\"");
              process.execute(context);
            } else {
              log.fine("Could not execute \"" + command + "\"");
            }
          } else if (type.getAsString().equals("cancel")) {
            WSProcessContext current = session.current.getAndSet(null);
View Full Code Here


                String command = lineVisitor.getRaw();
                lineBuffer.reset();
                if (command.length() > 0) {
                  term.addToHistory(command);
                }
                ShellProcess process = shell.createProcess(command);
                current =  new ProcessContext(this, process);
                status = Status.PROCESSING;
                return current;
              }
            }
View Full Code Here

      public String getName() {
        return userName;
      }
    };
    Shell shell = pluginContext.getPlugin(ShellFactory.class).create(user);
    ShellProcess shellProcess = shell.createProcess(command);

    //
    SSHInlineShellProcessContext context = new SSHInlineShellProcessContext(new SSHContext(env), shellProcess, out, err);
    int exitStatus = OK;
    String exitMsg = null;

    //
    try {
      shellProcess.execute(context);
    }
    catch (Exception e) {
      log.log(Level.SEVERE, "Error during command execution", e);
      exitMsg = e.getMessage();
      exitStatus = ERROR;
View Full Code Here

    // Test a bit
    ShellFactory factory = bootstrap.getContext().getPlugin(ShellFactory.class);
    Shell shell = factory.create(null);
    assertNotNull(shell);
    ShellProcess process = shell.createProcess("foo_cmd");
    assertNotNull(process);
    BaseProcessContext pc = BaseProcessContext.create(process).execute();
    assertTrue(pc.getResponse() instanceof ShellResponse.Ok);
    String r = pc.getOutput();
    assertEquals("bar", r);
View Full Code Here

    return task.def.getLine();
  }

  void run() {
    Shell sh = task.factory.create(null);
    ShellProcess sp = sh.createProcess(task.def.getLine());
    task.plugin.processes.add(this);
    task.plugin.history.add(this);
    while (task.plugin.history.size() > 100) {
      task.plugin.history.remove();
    }
    active = true;
    log.log(Level.FINE, "Started task with id=" + task.def.hashCode() + " pattern=" + task.def.getSchedullingPattern() " : "  + task.def.getLine());
    sp.execute(context);
  }
View Full Code Here

          Editor editor = (Editor)current;
          EditorAction action = editor.getMode().on(key);
          if (action != null) {
            String line = editor.append(action, key.sequence);
            if (line != null) {
              ShellProcess process = shell.createProcess(line);
              ProcessHandler context = new ProcessHandler(this, process);
              handler.set(context);
              process.execute(context);
            }
          }
        } else if (current instanceof ProcessHandler) {
          ProcessHandler processHandler = (ProcessHandler)current;
          ProcessHandler.Reader reader = processHandler.editor.get();
View Full Code Here

    t.start();

    //
    ServerAutomaton server = new ServerAutomaton(serverOOS, serverOIS);

    ShellProcess process = server.createProcess("hello");
    BaseProcessContext context = BaseProcessContext.create(process);
    context.execute();
    assertInstance(ShellResponse.Ok.class, context.getResponse());
    assertEquals("juu", context.getOutput());
View Full Code Here

    t.start();

    //
    ServerAutomaton server = new ServerAutomaton(serverOOS, serverOIS);

    ShellProcess process = server.createProcess("hello");
    BaseProcessContext context = BaseProcessContext.create(process);
    context.execute();
    ShellResponse response = context.getResponse();
    assertInstance(ShellResponse.Close.class, response);
View Full Code Here

    }));
    t.start();

    //
    ServerAutomaton server = new ServerAutomaton(serverOOS, serverOIS);
    ShellProcess process = server.createProcess("hello");
    final BaseProcessContext context = BaseProcessContext.create(process);

    //
    final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
    Thread u = new Thread() {
      @Override
      public void run() {
        context.execute();
        ShellResponse response = context.getResponse();
        assertInstance(ShellResponse.Cancelled.class, response);
      }
    };
    u.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
      public void uncaughtException(Thread t, Throwable e) {
        error.set(e);
      }
    });
    u.start();

    //
    synchronized (waiting) {
      if (!waiting.get()) {
        waiting.set(true);
        waiting.wait();
      }
    }

    //
    process.cancel();

    //
    latch.await();

    //
View Full Code Here

  public ShellProcess createProcess(final String request) throws IllegalStateException {
    synchronized (lock) {
      while (true) {
        if (queue.size() > 0) {
          final SyncProcess runnable = queue.removeFirst();
          return new ShellProcess() {
            @Override
            public void execute(ShellProcessContext processContext) throws IllegalStateException {
              try {
                runnable.run(request, processContext);
              }
View Full Code Here

TOP

Related Classes of org.crsh.shell.ShellProcess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.