Package com.jcraft.jsch

Examples of com.jcraft.jsch.ChannelExec.connect()


    protected void sendFileError(String path, String name, String data) throws Exception {
        ChannelExec c = (ChannelExec) session.openChannel("exec");
        OutputStream os = c.getOutputStream();
        InputStream is = c.getInputStream();
        c.setCommand("scp -t " + path);
        c.connect();
        assertEquals(0, is.read());
        os.write(("C7777 "+ data.length() + " " + name + "\n").getBytes());
        os.flush();
        assertEquals(2, is.read());
        c.disconnect();
View Full Code Here


    protected void sendDir(String path, String dirName, String fileName, String data) throws Exception {
        ChannelExec c = (ChannelExec) session.openChannel("exec");
        OutputStream os = c.getOutputStream();
        InputStream is = c.getInputStream();
        c.setCommand("scp -t -r " + path);
        c.connect();
        assertEquals(0, is.read());
        os.write(("D0755 0 " + dirName + "\n").getBytes());
        os.flush();
        assertEquals(0, is.read());
        os.write(("C7777 " + data.length() + " " + fileName + "\n").getBytes());
View Full Code Here

            public void run(IProgressMonitor monitor)
                throws InvocationTargetException {
              try {
                monitor.beginTask("View file from Distributed File System",
                    IProgressMonitor.UNKNOWN);
                exec.connect();
                BufferedInputStream stream =
                    new BufferedInputStream(exec.getInputStream());

                byte[] buffer = new byte[1024];
                int bytes;
View Full Code Here

            monitor.beginTask("Execute remote dfs  command", 100);
            try {
              exec = exec(" " + command);
              monitor.worked(33);

              exec.connect();
              monitor.worked(33);

              BufferedReader reader =
                  new BufferedReader(new InputStreamReader(
                      new BufferedInputStream(exec.getInputStream())));
View Full Code Here

          BufferedReader in =
              new BufferedReader(new InputStreamReader(
                  new BufferedInputStream(is)));

          if (!channel.isConnected()) {
            channel.connect();
          }

          try {
            // initial "found n items" line ignorable
            if (in.readLine() == null) {
View Full Code Here

              BufferedReader reader =
                  new BufferedReader(new InputStreamReader(
                      new BufferedInputStream(exec.getInputStream())));

              if (!monitor.isCanceled()) {
                exec.connect();
                String line = reader.readLine();
                sub.worked(1);
              }

              if (exec.isConnected()) {
View Full Code Here

              // mkdir
              try {
                channel = (ChannelExec) getSession().openChannel("exec");
                channel.setCommand(" mkdir " + to);
                InputStream in = channel.getInputStream();
                channel.connect();
                // in.read(); // wait for a response, which
                // we'll then ignore
              } catch (JSchException e) {
                // BUG(jz) abort operation and display error
                throw new RuntimeException(e);
View Full Code Here

                channel = (ChannelExec) getSession().openChannel("exec");
                (channel).setCommand("scp -p -t " + to);
                BufferedOutputStream out =
                    new BufferedOutputStream(channel.getOutputStream());
                InputStream in = channel.getInputStream();
                channel.connect();

                if (in.read() == 0) {
                  int step = (int) (100 / new File(from).length());
                  out.write(("C0644 " + new File(from).length() + " "
                      + new File(to).getName() + "\n").getBytes());
View Full Code Here

    ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);

    channel.setCommand(command);
    channel.setInputStream(null);

    channel.connect();
    new Thread() {
      @Override
      public void run() {
        try {
View Full Code Here

          ChannelExec channel2 = (ChannelExec) session.openChannel("exec");
          channel2.setCommand("rm -rf "
              + jarFile.substring(0, jarFile.lastIndexOf("/")));
          log.fine("Removing temp file "
              + jarFile.substring(0, jarFile.lastIndexOf("/")));
          channel2.connect();
          channel2.disconnect();

        } catch (Exception e) {
        }
      }
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.