1 31 package org.objectweb.proactive.core.process.ssh; 32 33 import org.objectweb.proactive.core.process.AbstractExternalProcessDecorator; 34 import org.objectweb.proactive.core.process.SimpleExternalProcess; 35 import org.objectweb.proactive.core.process.ExternalProcess; 36 37 54 55 public class SSHProcess extends AbstractExternalProcessDecorator { 56 57 61 65 public SSHProcess() { 66 super(); 67 68 } 69 70 75 public SSHProcess(ExternalProcess targetProcess) { 76 super(targetProcess); 77 } 78 79 80 84 public static void main(String [] args) { 85 try { 86 87 SSHProcess ssh = new SSHProcess(new SimpleExternalProcess("ls -lsa")); 88 ssh.setHostname("galere1.inria.fr"); 89 ssh.startProcess(); 90 91 } catch (Exception e) { 92 e.printStackTrace(); 93 } 94 } 95 96 97 101 protected String internalBuildCommand() { 102 return buildSSHCommand()+buildEnvironmentCommand(); 103 } 104 105 106 protected String buildSSHCommand() { 107 if (IS_WINDOWS_SYSTEM) { 108 return buildWindowsSSHCommand(); 109 } else { 110 return buildUnixSSHCommand(); 111 } 112 } 113 114 115 protected String buildUnixSSHCommand() { 116 StringBuffer command = new StringBuffer (); 117 command.append("ssh"); 118 if (username != null) { 120 command.append(" -l "); 121 command.append(username); 122 } 123 command.append(" "); 125 command.append(hostname); 126 command.append(" "); 127 if(logger.isDebugEnabled()){ 128 logger.debug(command.toString()); 129 } 130 return command.toString(); 131 } 132 133 134 protected String buildWindowsSSHCommand() { 135 StringBuffer command = new StringBuffer (); 136 command.append("ssh"); 137 command.append(" "); 138 command.append(hostname); 139 if (username != null) { 141 command.append(" -l "); 142 command.append(username); 143 } 144 command.append(" "); 146 return command.toString(); 147 } 148 149 150 154 } 155 | Popular Tags |