Session sess = conn.openSession(); sess.requestDumbPTY(); // Allocate a pseudo-terminal for this session. sess.startShell(); // Start a shell on the remote machine.
private void initSession() { try { session = conn.openSession(); session.requestDumbPTY(); session.startShell(); stdoutReader = new BufferedReader(new InputStreamReader( session.getStdout())); stderrReader = new BufferedReader(new InputStreamReader( session.getStderr())); out = new PrintWriter(session.getStdin()); } catch (Exception e) { String msg = "\nOpen SSH2 Session Error !"; logger.error(msg, e); throw new RuntimeException(msg, e); } }
scp.put(initScript.getBytes("UTF-8"),"init.sh",tmpDir,"0700"); Session sess = conn.openSession(); sess.requestDumbPTY(); // so that the remote side bundles stdout and stderr sess.execCommand(buildUpCommand(computer, tmpDir + "/init.sh")); sess.requestDumbPTY(); // so that the remote side bundles stdout and stderr sess.execCommand(buildUpCommand(computer, "touch ~/.hudson-run-init")); sess.close();
scp.put(initScript.getBytes("UTF-8"), "init.sh", tmpDir, "0700"); Session sess = conn.openSession(); sess.requestDumbPTY(); // so that the remote side bundles stdout sess.requestDumbPTY(); // so that the remote side bundles stdout