List of utility methods to do exec
String | executeShellCommand(String commandName) This method executes a shell command from Java String result = ""; Map<String, String> environment = new HashMap<String, String>(System.getenv()); environment.put("LC_ALL", "en_EN"); String[] envp = new String[environment.size()]; int count = 0; for (Map.Entry<String, String> entry : environment.entrySet()) { envp[count++] = entry.getKey() + "=" + entry.getValue(); try { Process p = Runtime.getRuntime().exec(commandName, envp); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = reader.readLine()) != null) { result += line + "\n"; return result; } catch (Exception e) { return result; |
String[] | executeShellScript(final String shellScript, final File tempDirectory) execute Shell Script final File shellFile = new File(tempDirectory, "tempFile_" + UUID.randomUUID() + ".sh"); final String fullPath = getFullPathName(shellFile); writeString(shellScript, shellFile); String[] cmd = { "chmod", "777", fullPath }; String[] res = executeCommandLineReturnAll(cmd); if (res == null || res.length != 0) { shellFile.delete(); return null; ... |
void | executeSMTPSend(String fromEmailAddress, List execute SMTP Send MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(fromEmailAddress)); message.setRecipients(RecipientType.TO, buildAddresses(toEmailAddresses.toArray(new String[toEmailAddresses.size()]))); message.setSubject(subject); MimeBodyPart textPart = new MimeBodyPart(); textPart.setText(body); Multipart multiPart = new MimeMultipart(); ... |
void | execVmCmdAsync(String vmNameSpace, String vmKey, String vmUser, String vmIp, String vmCmd, String controllerOutPutFile) exec Vm Cmd Async |
boolean | execWindowsCommand(String cmd) exec Windows Command if (cmd.contains("echo")) { String[] cmdParts = cmd.split(" > "); String fileContent = cmdParts[0].substring(5); try { final java.io.PrintWriter file = new java.io.PrintWriter(cmdParts[1]); file.println(fileContent); file.close(); ... |
void | execWithOutput(File dumpFile, String... args) exec With Output |
String | execWithResult(String cmd) exec With Result return execWithResult(cmd, false);
|