1 20 package org.jahia.utils; 21 22 23 import java.io.File ; 24 25 import org.jahia.exceptions.JahiaException; 26 27 32 public class JahiaCmdExec { 33 34 protected String m_Cmd = ""; 35 36 41 public JahiaCmdExec(String cmd) { 42 43 m_Cmd = cmd; 44 45 } 46 47 48 53 public void execute() throws JahiaException { 54 55 try { 56 57 Process process = Runtime.getRuntime().exec(m_Cmd); 58 59 } catch (Exception e) { 60 61 String errMsg = "Failed executing command line " + m_Cmd ; 62 JahiaConsole.println("JahiaCmdExec::execute()", errMsg + "\n" + e.toString()); 63 throw new JahiaException ("JahiaCmdExec", errMsg , 64 JahiaException.SERVICE_ERROR, JahiaException.WARNING_SEVERITY, e); 65 66 } 67 } 68 69 70 76 public void execute(File workingDir) throws JahiaException { 77 78 try { 79 Process process = Runtime.getRuntime().exec(m_Cmd,new String []{""},workingDir); 80 81 } catch (Exception e) { 82 83 String errMsg = "Failed executing command line " + m_Cmd ; 84 JahiaConsole.println("JahiaCmdExec::execute()", errMsg + "\n" + e.toString()); 85 throw new JahiaException ("JahiaCmdExec", errMsg , 86 JahiaException.SERVICE_ERROR, JahiaException.WARNING_SEVERITY, e); 87 88 } 89 } 90 91 92 } 93 94 | Popular Tags |