| java.lang.Object com.izforge.izpack.util.os.unix.ShellScript
ShellScript | public class ShellScript (Code) | | A Generator, Wrapper and Executor for Unix ShellScripts
author: marc.eppelmann@reddot.de |
Constructor Summary | |
public | ShellScript(String aShell) Creates and initializes the ShellScript for running on the given shell. | public | ShellScript() Creates and initializes the ShellScript for running on the bourne shell: "sh". |
Method Summary | |
public void | append(Object anObject) Appends an Object or String to this ShellScript. | public void | append(char aChar) Appends a Char to this ShellScript. | public void | appendln(Object anObject) Appends an Object or String to this ShellScript with unix linefeed ("\n"). | public void | appendln(char aChar) Appends a Char Object or String to this ShellScript with unix linefeed ("\n"). | public void | appendln() Appends an Object or String to this ShellScript with unix linefeed ("\n"). | public String | exec(String itsParams) Executes thsi ShellScript with the given Params.
NOTE: the params cannot be contain whitespaces.
This (su -c <br>"cp from to"</br>) would not work:
because the underlaying java.runtime.exec("command") does not handle balanced or unbalanced
(") correctly.
else just whitespace separate tokens.
This means for the sample. | public String | exec() Execute this ShellScript. | public static String | execAndDelete(String aShell, StringBuffer lines, String aLocation, String itsParams) Executes and removes the script.
The Lines be also written in python or perl,
In this case, the Shell must be python or perl or so.
Parameters: aShell - The Shell which should exec the script. | public static String | execAndDelete(StringBuffer lines, String aLocation) Executes and removes the script.
Parameters: lines - of the script. Parameters: aLocation - where to store. | public static String | execute(String aShell, StringBuffer lines, String aLocation, String itsParams) Execs ths given lines in the creted shell stored on location.
Parameters: aShell - A Shell which will be eexecute the script. Parameters: lines - The content of the script. Parameters: aLocation - The location where to store. Parameters: itsParams - Th eoptional params of the script. | public static String | execute(StringBuffer lines, String aLocation) Executes ths given lines in the created default shell (sh) stored on location. | public StringBuffer | getContent() gets the Content of this Script. | public String | getContentAsString() | public static void | main(String[] args) | public String | toString() Dumps the ShellScript Content, and Location. | public void | write(String aDestination) |
ShellScript | public ShellScript(String aShell)(Code) | | Creates and initializes the ShellScript for running on the given shell.
Parameters: aShell - "sh", "bash", "ksh", "csh" and so an... |
ShellScript | public ShellScript()(Code) | | Creates and initializes the ShellScript for running on the bourne shell: "sh".
|
append | public void append(Object anObject)(Code) | | Appends an Object or String to this ShellScript.
Parameters: anObject - the Object to append |
append | public void append(char aChar)(Code) | | Appends a Char to this ShellScript.
Parameters: aChar - a char to append |
appendln | public void appendln(Object anObject)(Code) | | Appends an Object or String to this ShellScript with unix linefeed ("\n").
Parameters: anObject - the Object to append |
appendln | public void appendln(char aChar)(Code) | | Appends a Char Object or String to this ShellScript with unix linefeed ("\n").
Parameters: aChar - a char to append |
appendln | public void appendln()(Code) | | Appends an Object or String to this ShellScript with unix linefeed ("\n").
|
exec | public String exec(String itsParams)(Code) | | Executes thsi ShellScript with the given Params.
NOTE: the params cannot be contain whitespaces.
This (su -c <br>"cp from to"</br>) would not work:
because the underlaying java.runtime.exec("command") does not handle balanced or unbalanced
(") correctly.
else just whitespace separate tokens.
This means for the sample. runtime.exec() would ever execute such as: su "-c" "\"cp"
"fromFile" "toFile\""
But this his hidden in Sun's native code ;-(
This was the reason to write thsi class to have a Workaround :-)
Parameters: itsParams - the output from stdout of the execution. |
exec | public String exec()(Code) | | Execute this ShellScript.
the output from stdout of the execution. |
execAndDelete | public static String execAndDelete(String aShell, StringBuffer lines, String aLocation, String itsParams)(Code) | | Executes and removes the script.
The Lines be also written in python or perl,
In this case, the Shell must be python or perl or so.
Parameters: aShell - The Shell which should exec the script. Can be also be python or perl, if theshellcontent is given in this language. Parameters: lines - of the script. Parameters: aLocation - where to store. Parameters: itsParams - which should be pass to the script. the stdout. |
execAndDelete | public static String execAndDelete(StringBuffer lines, String aLocation)(Code) | | Executes and removes the script.
Parameters: lines - of the script. Parameters: aLocation - where to store. the sdtout. |
execute | public static String execute(String aShell, StringBuffer lines, String aLocation, String itsParams)(Code) | | Execs ths given lines in the creted shell stored on location.
Parameters: aShell - A Shell which will be eexecute the script. Parameters: lines - The content of the script. Parameters: aLocation - The location where to store. Parameters: itsParams - Th eoptional params of the script. the exec result |
execute | public static String execute(StringBuffer lines, String aLocation)(Code) | | Executes ths given lines in the created default shell (sh) stored on location.
Parameters: lines - the lines of the script to exec.s Parameters: aLocation - where to store the stdout of the script. |
getContent | public StringBuffer getContent()(Code) | | gets the Content of this Script.
the Content |
getContentAsString | public String getContentAsString()(Code) | | Gets the Content of this Script as String
the script as String |
main | public static void main(String[] args)(Code) | | Test Main Method Run test with: java -cp .jar com.izforge.izpack.util.os.unix.ShellScript
Parameters: args - Arguments from Commandline |
toString | public String toString()(Code) | | Dumps the ShellScript Content, and Location.
Use getContentAsString() to get this ShellScripts Content
The ShellScript as Object dump. |
write | public void write(String aDestination)(Code) | | write this to the given Destination FileName
Parameters: aDestination - a destination filename |
|
|