Examples of ShellProcess


Examples of org.crsh.shell.ShellProcess

      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

Examples of org.crsh.shell.ShellProcess

    // 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

Examples of org.crsh.shell.ShellProcess

    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

Examples of org.crsh.shell.ShellProcess

          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

Examples of org.crsh.shell.ShellProcess

    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

Examples of org.crsh.shell.ShellProcess

    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

Examples of org.crsh.shell.ShellProcess

    }));
    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

Examples of org.crsh.shell.ShellProcess

  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

Examples of org.jbits.javashell.ShellProcess

  private ShellPipeCollector c;
  private List<String> output = null;
  private float totalTimeMilliseconds = Float.NaN;

  private OS(String command, String ... args ) {
    this.p = new ShellProcess(command);
    c = new ShellPipeCollector();
    p.addOutputListener(c);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.