Class ScriptExecutor


  • public class ScriptExecutor
    extends java.lang.Object
    Class to execute Shell Scripts
    Author:
    f.conrads
    • Constructor Summary

      Constructors 
      Constructor Description
      ScriptExecutor()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int exec​(java.lang.String file, java.lang.String[] args)
      Will execute the given file with the provided arguments via Shell.
      static int execSafe​(java.lang.String file, java.lang.String[] args)
      Checks if file contains arguments itself
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScriptExecutor

        public ScriptExecutor()
    • Method Detail

      • exec

        public static int exec​(java.lang.String file,
                               java.lang.String[] args)
                        throws org.apache.commons.exec.ExecuteException,
                               java.io.IOException
        Will execute the given file with the provided arguments via Shell.
        Parameters:
        file - file to execute
        args - arguments to execute file with
        Returns:
        Process return, 0 means everything worked fine
        Throws:
        org.apache.commons.exec.ExecuteException - if script can't be executed
        java.io.IOException - if file IO errors
      • execSafe

        public static int execSafe​(java.lang.String file,
                                   java.lang.String[] args)
                            throws org.apache.commons.exec.ExecuteException,
                                   java.io.IOException
        Checks if file contains arguments itself
        Parameters:
        file - file to execute
        args - arguments to execute file with
        Returns:
        Process return, 0 means everything worked fine
        Throws:
        org.apache.commons.exec.ExecuteException - if script can't be executed
        java.io.IOException - if file IO errors