Esempio n. 1
0
  public boolean executeRemoteCommand(IProgressMonitor monitor, String command, String[] args)
      throws CoreException {
    if (remoteConnection == null) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              EnvironmentPlugin.getUniqueIdentifier(),
              Messages.SSHTargetControl_5,
              null));
    }

    for (int i = 0; i < args.length; i++) {
      command += (" " + args[i]); // $NON-NLS-1$
    }

    try {
      IRemoteExecutionManager executionManager = remoteConnection.createRemoteExecutionManager();
      executionManager.getExecutionTools().executeWithExitValue(command);
      executionManager.close();
      return true;
    } catch (RemoteConnectionException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              EnvironmentPlugin.getUniqueIdentifier(),
              0,
              Messages.SSHTargetControl_2,
              e));
    } catch (CancelException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              EnvironmentPlugin.getUniqueIdentifier(),
              0,
              Messages.SSHTargetControl_3,
              e));
    } catch (RemoteExecutionException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              EnvironmentPlugin.getUniqueIdentifier(),
              0,
              Messages.SSHTargetControl_4,
              e));
    }
  }
Esempio n. 2
0
 /**
  * Create a remote execution manager that may be used to do operations on the remote target
  * environment.
  *
  * @return
  * @throws RemoteConnectionException
  */
 protected IRemoteExecutionManager createRemoteExecutionManager()
     throws RemoteConnectionException {
   return remoteConnection.createRemoteExecutionManager();
 }