1 31 package org.objectweb.proactive.core.process.rsh; 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 58 59 public class RSHProcess extends AbstractExternalProcessDecorator { 60 61 68 public RSHProcess() { 69 super(); 70 } 71 72 73 78 public RSHProcess(ExternalProcess targetProcess) { 79 super(targetProcess); 80 } 81 82 83 87 public static void main(String [] args) { 88 try { 89 RSHProcess rsh = new RSHProcess(new SimpleExternalProcess("ls -lsa")); 90 rsh.setHostname("solida"); 91 rsh.startProcess(); 92 } catch (Exception e) { 93 e.printStackTrace(); 94 } 95 } 96 97 98 102 protected String internalBuildCommand() { 103 return buildRSHCommand()+buildEnvironmentCommand(); 104 } 105 106 107 protected String buildRSHCommand() { 108 if (IS_WINDOWS_SYSTEM) { 109 return buildWindowsRSHCommand(); 110 } else { 111 return buildUnixRSHCommand(); 112 } 113 } 114 115 116 protected String buildUnixRSHCommand() { 117 StringBuffer command = new StringBuffer (); 118 command.append("rsh"); 119 if (username != null) { 121 command.append(" -l "); 122 command.append(username); 123 } 124 command.append(" "); 126 command.append(hostname); 127 command.append(" "); 128 return command.toString(); 129 } 130 131 132 protected String buildWindowsRSHCommand() { 133 StringBuffer command = new StringBuffer (); 134 command.append("rsh"); 135 command.append(" "); 136 command.append(hostname); 137 if (username != null) { 139 command.append(" -l "); 140 command.append(username); 141 } 142 command.append(" "); 144 return command.toString(); 145 } 146 147 148 152 } 153 | Popular Tags |