public class ShellScript extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
BASH |
static String |
BOURNE_AGAIN_SHELL |
static String |
BOURNE_SHELL |
static String |
SH |
| Constructor and Description |
|---|
ShellScript()
Creates and initializes the ShellScript for running on the bourne shell: "sh".
|
ShellScript(String aShell)
Creates and initializes the ShellScript for running on the given shell.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(char aChar)
Appends a Char to this ShellScript.
|
void |
append(Object anObject)
Appends an Object or String to this ShellScript.
|
void |
append(String[] anArray)
Appends the Array as one Commandline Space Separated
This is usefull with our FileExecutor
|
void |
appendln()
Appends an unix linefeed to this script ("\n").
|
void |
appendln(char aChar)
Appends a Char Object or String to this ShellScript with unix linefeed ("\n").
|
void |
appendln(Object anObject)
Appends an Object or String to this ShellScript with unix linefeed ("\n").
|
void |
appendln(String[] anArray)
Appends the Array as ONE!
|
void |
delete()
Deletes only if Location is not null.
|
String |
exec()
Execute this ShellScript.
|
String |
exec(String itsParams)
Executes this ShellScript with the given Params.
|
static String |
execAndDelete(StringBuffer lines,
String aLocation)
Executes and removes the script.
|
static String |
execAndDelete(String aShell,
StringBuffer lines,
String aLocation,
String itsParams)
Executes and removes the script.
|
static String |
execute(StringBuffer lines,
String aLocation)
Executes ths given lines in the created default shell (sh) stored on location.
|
static String |
execute(String aShell,
StringBuffer lines,
String aLocation,
String itsParams)
Execs ths given lines in the creted shell stored on location.
|
StringBuffer |
getContent()
gets the Content of this Script.
|
String |
getContentAsString()
Gets the Content of this Script as String
|
String |
getShell()
Gets the current used shell.
|
static void |
main(String[] args)
Test Main Method Run test with: java -cp .jar com.izforge.izpack.util.unix.ShellScript
|
void |
setShell(String aShell)
Sets the current used shell
|
String |
toString()
Dumps the ShellScript Content, and Location.
|
void |
write(String aDestination)
write this to the given Destination FileName
|
public static final String SH
public static final String BOURNE_SHELL
public static final String BASH
public static final String BOURNE_AGAIN_SHELL
public ShellScript(String aShell)
aShell - "sh", "bash", "ksh", "csh" and so an...public ShellScript()
public void setShell(String aShell)
aShell - The Shell which should set and used.public String getShell()
public void append(Object anObject)
anObject - the Object to appendpublic void append(char aChar)
aChar - a char to appendpublic void append(String[] anArray)
anArray - public void appendln(String[] anArray)
anArray - public void appendln(Object anObject)
anObject - the Object to appendpublic void appendln(char aChar)
aChar - a char to appendpublic void appendln()
public StringBuffer getContent()
public String getContentAsString()
public String toString()
public void write(String aDestination)
aDestination - a destination filenamepublic String exec(String itsParams)
itsParams - public String exec()
public static String execute(String aShell, StringBuffer lines, String aLocation, String itsParams)
aShell - A Shell which will be eexecute the script.lines - The content of the script.aLocation - The location where to store.itsParams - Th eoptional params of the script.public static String execute(StringBuffer lines, String aLocation)
lines - the lines of the script to exec.saLocation - where to storepublic static String execAndDelete(String aShell, StringBuffer lines, String aLocation, String itsParams)
aShell - The Shell which should exec the script. Can be also be python or perl, if the
shellcontent is given in this language.lines - of the script.aLocation - where to store.itsParams - which should be pass to the script.public static String execAndDelete(StringBuffer lines, String aLocation)
lines - of the script.aLocation - where to store.public static void main(String[] args)
args - Arguments from Commandlinepublic void delete()
Copyright © 2001–2025. All rights reserved.