Package Torello.Java
Class Shell
- java.lang.Object
-
- Torello.Java.OSCommands
-
- Torello.Java.Shell
-
- All Implemented Interfaces:
java.lang.Cloneable
public class Shell extends OSCommands implements java.lang.Cloneable
This Class ExtendsOSCommands
:
ClassOSCommands
is the parent class for all classes which invoke Operating-System Processes using the Java-Standardjava.lang.Process
Object-Utility.OSCommands
has several constructors inherited by this class which allow a user to configure this class for sending its output in any number of ways toAppendable
instances / loggers of your choice. Read this class documentation about invoking a constructor using any number of log-configurations, for sending text-output to any neccessary destination.
All Methods ReturnOSResponse
:
In addition to real-time process-output printing, this class will collect any all text sent to Standard-Output and Error-Output and save theString
-data for return to the user. All Operating-System calls in this class (which are all invoked by these methods, below) will always return an instance ofOSResponse
.
ClassOSResponse
also contains the fieldresponse
, which signals what the OS-Process' return-value was. Operating-Systems, generally, return a'0'
to indicate the process ran to completion without errors, and some other value to signal an error occurred.
ClassOSExtras
has All Additionaljava.lang.Process
Features:java.lang.Process
allows a user to redirect output, and collect-input to and from any number of additional sources. There is copious documentation aboutOSExtras
, explaining these features.
To specialize an Operating-System call with anOSExtras
instance, just call this class'setOSExtras(...)
method, with any neccessary configurations.A great tool for working with a UNIX operating-system, and invoking common UNIX commands - this class simply converts many of the old UNIX-BASH shell commands into a simple Java API.
See Wikipedia:
Below is an example that uses this class'TAR'
command to create an archive of all'.java'
files in theNodeSearch
package ofvthis jar-library. Please note that, at the UNIX command line, a simple wild-card would suffice, but when invoking a shell command from Java, the file-names will not be expanded.
Example:
import Torello.Java.*; import static Torello.Java.FileNode.RetTypeChoice.*; import java.util.stream.*; import java.io.IOException; public class WildCards { public static void main(String[] argv) throws IOException { // Create a new instance. Print all output to System.out and System.err Shell shell = new Shell(System.out, System.err); // This uses the 'FileNode' class to retrieve all '.java' source-files // that are located in directory "NodeSearch/", and any sub-directories it has. Stream<String> fileNames = FileNode .createRoot("Torello/HTML/NodeSearch/") .loadTree() .flattenJustFiles(FULLPATH_STREAM, -1, (FileNode fn) -> fn.name.endsWith(".java")); // These are the rest of the parameters for the UNIX 'tar' (file-archive) command Stream<String> command = Stream.of("-cvf", "MySourceFiles.tar"); // Creates a '.tar' of all java source files that were found. OSResponse osr = shell.TAR(Stream.concat(command, fileNames).toArray(String[]::new)); if (osr.response != 0) System.err.println("There were errros"). } }
The above code print the following output to terminal.
UNIX or DOS Shell Command:
tar -cvf MySourceFiles.tar Torello/HTML/NodeSearch/CSSStrException.java Torello/HTML/NodeSearch/TagNodePeekInclusive.java Torello/HTML/NodeSearch/TagNodeIterator.java Torello/HTML/NodeSearch/CommentNodeFind.java Torello/HTML/NodeSearch/InnerTagRemove.java Torello/HTML/NodeSearch/TagNodeGetInclusive.java Torello/HTML/NodeSearch/TextNodePoll.java Torello/HTML/NodeSearch/SecondModificationException.java Torello/HTML/NodeSearch/TagNodeGet.java Torello/HTML/NodeSearch/CommentNodePoll.java Torello/HTML/NodeSearch/TagNodePeekL1Inclusive.java Torello/HTML/NodeSearch/TextNodeFind.java Torello/HTML/NodeSearch/CommentNodeCount.java Torello/HTML/NodeSearch/TextNodePeek.java Torello/HTML/NodeSearch/TagNodeFind.java Torello/HTML/NodeSearch/IteratorOutOfBoundsException.java Torello/HTML/NodeSearch/AVT.java Torello/HTML/NodeSearch/package-info.java Torello/HTML/NodeSearch/InnerTagInclusiveIterator.java Torello/HTML/NodeSearch/InnerTagFindInclusive.java Torello/HTML/NodeSearch/InnerTagGetInclusive.java Torello/HTML/NodeSearch/TextNodeIterator.java Torello/HTML/NodeSearch/JS.java Torello/HTML/NodeSearch/HTMLNotFoundException.java Torello/HTML/NodeSearch/TagNodeFindL1Inclusive.java Torello/HTML/NodeSearch/TagNodeGetL1Inclusive.java Torello/HTML/NodeSearch/CommentNodeRemove.java Torello/HTML/NodeSearch/InnerTagRemoveInclusive.java Torello/HTML/NodeSearch/InnerTagPollInclusive.java Torello/HTML/NodeSearch/InnerTagFind.java Torello/HTML/NodeSearch/TextNodeGet.java Torello/HTML/NodeSearch/TagNodeCount.java Torello/HTML/NodeSearch/CommentNodePeek.java Torello/HTML/NodeSearch/InnerTagPeek.java Torello/HTML/NodeSearch/CommentNodeGet.java Torello/HTML/NodeSearch/InnerTagCount.java Torello/HTML/NodeSearch/InclusiveException.java Torello/HTML/NodeSearch/TagNodeRemove.java Torello/HTML/NodeSearch/TagNodeFindInclusive.java Torello/HTML/NodeSearch/HNLIInclusive.java Torello/HTML/NodeSearch/TextNodeCount.java Torello/HTML/NodeSearch/TCCompareStrException.java Torello/HTML/NodeSearch/CursorException.java Torello/HTML/NodeSearch/TagNodeRemoveInclusive.java Torello/HTML/NodeSearch/TextComparitor.java Torello/HTML/NodeSearch/CommentNodeIterator.java Torello/HTML/NodeSearch/InnerTagGet.java Torello/HTML/NodeSearch/TagNodeInclusiveIterator.java Torello/HTML/NodeSearch/ARGCHECK.java Torello/HTML/NodeSearch/InnerTagPoll.java Torello/HTML/NodeSearch/InnerTagPeekInclusive.java Torello/HTML/NodeSearch/AbstractHNLI.java Torello/HTML/NodeSearch/TagNodePeek.java Torello/HTML/NodeSearch/TagNodePoll.java Torello/HTML/NodeSearch/InnerTagIterator.java Torello/HTML/NodeSearch/HNLI.java Torello/HTML/NodeSearch/TagNodePollInclusive.java Torello/HTML/NodeSearch/TextNodeRemove.java Torello/HTML/NodeSearch/searchLoops/TNRemove.java Torello/HTML/NodeSearch/searchLoops/ITFind.java Torello/HTML/NodeSearch/searchLoops/CmtNPoll.java Torello/HTML/NodeSearch/searchLoops/ITGetIncl.java Torello/HTML/NodeSearch/searchLoops/ITFindIncl.java Torello/HTML/NodeSearch/searchLoops/TNFindL1Incl.java Torello/HTML/NodeSearch/searchLoops/TNGetL1Incl.java Torello/HTML/NodeSearch/searchLoops/TNPeekL1Incl.java Torello/HTML/NodeSearch/searchLoops/ITGet.java Torello/HTML/NodeSearch/searchLoops/TxNPeek.java Torello/HTML/NodeSearch/searchLoops/TNPeek.java Torello/HTML/NodeSearch/searchLoops/TxNGet.java Torello/HTML/NodeSearch/searchLoops/TNCount.java Torello/HTML/NodeSearch/searchLoops/TNPoll.java Torello/HTML/NodeSearch/searchLoops/TNGetIncl.java Torello/HTML/NodeSearch/searchLoops/TNFindIncl.java Torello/HTML/NodeSearch/searchLoops/CmtNFind.java Torello/HTML/NodeSearch/searchLoops/TxNFind.java Torello/HTML/NodeSearch/searchLoops/TNFind.java Torello/HTML/NodeSearch/searchLoops/TxNCount.java Torello/HTML/NodeSearch/searchLoops/TNGet.java Torello/HTML/NodeSearch/searchLoops/TNRemoveIncl.java Torello/HTML/NodeSearch/searchLoops/ITPeek.java Torello/HTML/NodeSearch/searchLoops/ITCount.java Torello/HTML/NodeSearch/searchLoops/TNPeekIncl.java Torello/HTML/NodeSearch/searchLoops/ITPeekIncl.java Torello/HTML/NodeSearch/searchLoops/TxNPoll.java Torello/HTML/NodeSearch/searchLoops/ITPollIncl.java Torello/HTML/NodeSearch/searchLoops/TNPollIncl.java Torello/HTML/NodeSearch/searchLoops/ITRemoveIncl.java Torello/HTML/NodeSearch/searchLoops/TxNRemove.java Torello/HTML/NodeSearch/searchLoops/CmtNRemove.java Torello/HTML/NodeSearch/searchLoops/CmtNGet.java Torello/HTML/NodeSearch/searchLoops/CmtNCount.java Torello/HTML/NodeSearch/searchLoops/ITPoll.java Torello/HTML/NodeSearch/searchLoops/CmtNPeek.java Torello/HTML/NodeSearch/searchLoops/ITRemove.java Torello/HTML/NodeSearch/CSSStrException.java Torello/HTML/NodeSearch/TagNodePeekInclusive.java Torello/HTML/NodeSearch/TagNodeIterator.java Torello/HTML/NodeSearch/CommentNodeFind.java Torello/HTML/NodeSearch/InnerTagRemove.java Torello/HTML/NodeSearch/TagNodeGetInclusive.java Torello/HTML/NodeSearch/TextNodePoll.java Torello/HTML/NodeSearch/SecondModificationException.java Torello/HTML/NodeSearch/TagNodeGet.java Torello/HTML/NodeSearch/CommentNodePoll.java Torello/HTML/NodeSearch/TagNodePeekL1Inclusive.java Torello/HTML/NodeSearch/TextNodeFind.java Torello/HTML/NodeSearch/CommentNodeCount.java Torello/HTML/NodeSearch/TextNodePeek.java Torello/HTML/NodeSearch/TagNodeFind.java Torello/HTML/NodeSearch/IteratorOutOfBoundsException.java Torello/HTML/NodeSearch/AVT.java Torello/HTML/NodeSearch/package-info.java Torello/HTML/NodeSearch/InnerTagInclusiveIterator.java Torello/HTML/NodeSearch/InnerTagFindInclusive.java Torello/HTML/NodeSearch/InnerTagGetInclusive.java Torello/HTML/NodeSearch/TextNodeIterator.java Torello/HTML/NodeSearch/JS.java Torello/HTML/NodeSearch/HTMLNotFoundException.java Torello/HTML/NodeSearch/TagNodeFindL1Inclusive.java Torello/HTML/NodeSearch/TagNodeGetL1Inclusive.java Torello/HTML/NodeSearch/CommentNodeRemove.java Torello/HTML/NodeSearch/InnerTagRemoveInclusive.java Torello/HTML/NodeSearch/InnerTagPollInclusive.java Torello/HTML/NodeSearch/InnerTagFind.java Torello/HTML/NodeSearch/TextNodeGet.java Torello/HTML/NodeSearch/TagNodeCount.java Torello/HTML/NodeSearch/CommentNodePeek.java Torello/HTML/NodeSearch/InnerTagPeek.java Torello/HTML/NodeSearch/CommentNodeGet.java Torello/HTML/NodeSearch/InnerTagCount.java Torello/HTML/NodeSearch/InclusiveException.java Torello/HTML/NodeSearch/TagNodeRemove.java Torello/HTML/NodeSearch/TagNodeFindInclusive.java Torello/HTML/NodeSearch/HNLIInclusive.java Torello/HTML/NodeSearch/TextNodeCount.java Torello/HTML/NodeSearch/TCCompareStrException.java Torello/HTML/NodeSearch/CursorException.java Torello/HTML/NodeSearch/TagNodeRemoveInclusive.java Torello/HTML/NodeSearch/TextComparitor.java Torello/HTML/NodeSearch/CommentNodeIterator.java Torello/HTML/NodeSearch/InnerTagGet.java Torello/HTML/NodeSearch/TagNodeInclusiveIterator.java Torello/HTML/NodeSearch/ARGCHECK.java Torello/HTML/NodeSearch/InnerTagPoll.java Torello/HTML/NodeSearch/InnerTagPeekInclusive.java Torello/HTML/NodeSearch/AbstractHNLI.java Torello/HTML/NodeSearch/TagNodePeek.java Torello/HTML/NodeSearch/TagNodePoll.java Torello/HTML/NodeSearch/InnerTagIterator.java Torello/HTML/NodeSearch/HNLI.java Torello/HTML/NodeSearch/TagNodePollInclusive.java Torello/HTML/NodeSearch/TextNodeRemove.java Torello/HTML/NodeSearch/searchLoops/TNRemove.java Torello/HTML/NodeSearch/searchLoops/ITFind.java Torello/HTML/NodeSearch/searchLoops/CmtNPoll.java Torello/HTML/NodeSearch/searchLoops/ITGetIncl.java Torello/HTML/NodeSearch/searchLoops/ITFindIncl.java Torello/HTML/NodeSearch/searchLoops/TNFindL1Incl.java Torello/HTML/NodeSearch/searchLoops/TNGetL1Incl.java Torello/HTML/NodeSearch/searchLoops/TNPeekL1Incl.java Torello/HTML/NodeSearch/searchLoops/ITGet.java Torello/HTML/NodeSearch/searchLoops/TxNPeek.java Torello/HTML/NodeSearch/searchLoops/TNPeek.java Torello/HTML/NodeSearch/searchLoops/TxNGet.java Torello/HTML/NodeSearch/searchLoops/TNCount.java Torello/HTML/NodeSearch/searchLoops/TNPoll.java Torello/HTML/NodeSearch/searchLoops/TNGetIncl.java Torello/HTML/NodeSearch/searchLoops/TNFindIncl.java Torello/HTML/NodeSearch/searchLoops/CmtNFind.java Torello/HTML/NodeSearch/searchLoops/TxNFind.java Torello/HTML/NodeSearch/searchLoops/TNFind.java Torello/HTML/NodeSearch/searchLoops/TxNCount.java Torello/HTML/NodeSearch/searchLoops/TNGet.java Torello/HTML/NodeSearch/searchLoops/TNRemoveIncl.java Torello/HTML/NodeSearch/searchLoops/ITPeek.java Torello/HTML/NodeSearch/searchLoops/ITCount.java Torello/HTML/NodeSearch/searchLoops/TNPeekIncl.java Torello/HTML/NodeSearch/searchLoops/ITPeekIncl.java Torello/HTML/NodeSearch/searchLoops/TxNPoll.java Torello/HTML/NodeSearch/searchLoops/ITPollIncl.java Torello/HTML/NodeSearch/searchLoops/TNPollIncl.java Torello/HTML/NodeSearch/searchLoops/ITRemoveIncl.java Torello/HTML/NodeSearch/searchLoops/TxNRemove.java Torello/HTML/NodeSearch/searchLoops/CmtNRemove.java Torello/HTML/NodeSearch/searchLoops/CmtNGet.java Torello/HTML/NodeSearch/searchLoops/CmtNCount.java Torello/HTML/NodeSearch/searchLoops/ITPoll.java Torello/HTML/NodeSearch/searchLoops/CmtNPeek.java Torello/HTML/NodeSearch/searchLoops/ITRemove.java Command exit with return value 0
WORA:
In its inception, Java made the "Write Once, Run Anywhere" (WORA) pledge. The methods in this class are not in any way "Java-ized" versions of the Operating System Calls. Rather, they are just wrappers aroundjava.lang.Process
allowing a user to BOTH make Operating System calls easily AND to efficiently retrieve the generated text-output produced by the calls.
The bulk-work of the classes in this JAR Library were written and tested in a UNIX environment. While everything in the HTML Package ofJava HTML JAR
is indeed, O/S Independent (adhering to 'WORA'), this class and all classes which extendOSCommands
are highly O/S dependent. The methods in these classes are (for all intents and purposes) a set of hooks into native Operating System calls.
This means that an invocation of these methods while running in the wrong Operating System will just return a bunch of error-output results and thrown exceptions.
Synchronized Methods:
The vast majority of the methods in classOSCommands
are synchronized. Specifically, the methods are declared using the Java Key-Wordsynchronized
(even though Java Doc doesn't output that particular word into its method declarations). This also means that all classes extending and inheritingOSCommands
will all have Thread-Safe andsynchronized
methods.
Whenever a command is issued to this class, execution control for the current thread will not proceed / continue until the external operating system process has finished What that does mean, is that if this class were used by two different threads inside of a multi-threaded application, only one thread would ever be allowed to use this class. If you have a program that needs more than one thread making O/S calls, simply construct a second instance of this class (one for each thread), and any 'locking problems' should be resolved.
Wild Cards:
The behavior of expanding an'*'
or'?'
is another somewhat Operating-System Dependent phenomenon. It may be the case that Wild-Cards are expanded by the Operating-System, before the call. In such scenarios, when Java makes a call to the O/S it must have expanded its Wild-Cards.- See Also:
OSCommands
,OSResponse
Hi-Lited Source-Code:- View Here: Torello/Java/Shell.java
- Open New Browser-Tab: Torello/Java/Shell.java
-
-
Field Summary
-
Fields inherited from class Torello.Java.OSCommands
appendable, cmdOrCmdAndOutput, errorOutput, osExtras, printCmdAppendable, standardOutput
-
-
Constructor Summary
Constructors Constructor Shell()
Shell(Appendable appendable, boolean cmdOrCmdAndOutput, Appendable printCmdAppendable)
Shell(Appendable appendable, boolean cmdOrCmdAndOutput, Appendable printCmdAppendable, Appendable standardOutput, Appendable errorOutput)
Shell(Appendable standardOutput, Appendable errorOutput)
-
Method Summary
Copy Files & Directories Modifier and Type Method OSResponse
CP(String[] src, String target)
OSResponse
CP(String src, String target)
OSResponse
CP(Vector<String> src, String target)
Move Files & Directories Modifier and Type Method OSResponse
MV(String[] src, String target)
OSResponse
MV(String src, String target)
OSResponse
MV(Vector<String> src, String target)
Removing Files & Directories Modifier and Type Method OSResponse
RM(String s1)
OSResponse
RM(String[] sArr)
OSResponse
RM(String s1, String switches)
OSResponse
RM(Vector<String> v)
Listing Files & Directories Modifier and Type Method OSResponse
LS(String fileOrDir)
OSResponse
LS(String fileOrDir, String switches)
Common UNIX Commands Modifier and Type Method OSResponse
CHMOD(String... args)
OSResponse
CHOWN(String... args)
OSResponse
CMP(String... args)
OSResponse
DATE(String... args)
OSResponse
DF(String... args)
OSResponse
DIFF(String... args)
OSResponse
DU(String... args)
OSResponse
FIND(String... args)
OSResponse
FREE(String... args)
OSResponse
FSCK(String... args)
OSResponse
GREP(String... args)
OSResponse
GZIP(String... args)
OSResponse
JAR(String... args)
OSResponse
JAVA(String... args)
OSResponse
JAVAC(String... args)
OSResponse
JAVADOC(String... args)
OSResponse
NSLOOKUP(String... args)
OSResponse
PING(String... args)
OSResponse
PS(String... args)
OSResponse
SED(String... args)
OSResponse
SORT(String... args)
OSResponse
TAR(String... args)
OSResponse
TIME(String... args)
OSResponse
TRACEROUTE(String... args)
OSResponse
UNZIP(String... args)
OSResponse
VMSTAT(String... args)
OSResponse
WHATIS(String... args)
OSResponse
WHEREIS(String... args)
Any UNIX Command Modifier and Type Method OSResponse
COMMAND(String COMMAND_NAME, String... args)
Methods: interface java.lang.Cloneable Modifier and Type Method Shell
clone()
-
Methods inherited from class Torello.Java.OSCommands
appendable, commandToString, equals, errorOutput, printAndRun, printCmdAppendable, run, run, setAll, setAppendable, setOSExtras, setStandardAndErrorOutput, standardOutput, toString
-
-
-
-
Constructor Detail
-
Shell
public Shell()
Default constructor for instances inheriting this class. This constructor assigns the default values to all of the output loggingAppendable's
. This constructor's "See Also" section has a link to each of the loggingAppendable's
provided by this class.
Note that all of them are assigned 'null' - meaing their output will not be logged - except for the primary fieldthis.appendable
. This field is assignedSystem.out
, meaning that all text output by a process will be sent to the terminal window.
Description copied in entirety from:OSCommands()
- See Also:
OSCommands()
- Code:
- Exact Constructor Body:
super();
-
Shell
public Shell(java.lang.Appendable appendable, boolean cmdOrCmdAndOutput, java.lang.Appendable printCmdAppendable)
This constructor allows a user to assign theAppendable's
:appendable
&printCmdAppendable
.
The first collects all text-output generated by the processes and prints it using theAppendable's
printing methods. This includes text generated for BOTHStandard-Output
ANDError-Output
. This text is collected in real time as it is output by the underlying process.
The secondAppendable
merely accepts the requested command, itself, as an outputString
. ThisString
is printed using theAppendable's
append(...)
methods.
NOTE: Either of theseAppendable's
may be assigned null, and if they are, they are simply ignored.NullPointerException
won't throw, and the output text will simply not be printed.
Description copied in entirety from:OSCommands(Appendable, boolean, Appendable)
- Parameters:
appendable
- This parameter's reference is assigned directly to theOSCommands
field:appendable
. To clearly understand the use of this field, please review the documentation linked for that field. To summarize, thejava.lang.Appendable
that is synonymously namedappendable
simply collects all output text generated by a processes as it executes, and sends it to the reference'sappend(...)
method. This text will include that sent to BOTHStandard-Output
AND text sent toError-Output
. The text that is printed is transmitted in the order it is received from the reader-threads that read the underlying process' text-pipes.
By default this parameter is assignedSystem.out
. When this default value is used, it means that as the process executes, any and all text it prints is sent to the UNIX or MS-DOS Operating System Terminal Window.
This field may be assigned null, and when so it is just ignored. Assigning null toappendable
. will not produce aNullPointerException
.cmdOrCmdAndOutput
- Thisboolean
is assigned to theOSCommands
field namedcmdOrCmdAndOutput
.
Please review the documentation for that field to understand clearly the use of this parameter.printCmdAppendable
- Thisjava.lang.Appendable
allows for yet another output mechanism when executing operating system commands. The sole purpose of thisAppendable
is to print the process command, itself, as a JavaString
- exactly as it was issued to the operating system.
This allows a type of "Monitor Log" to store all commands being issued to the Operating-System, without having to include the full-text output that those process calls have produced. The value passed to this parameter is assigned to theOSCommands
field namedprintCmdAppendable
.
This parameter may be null, and if it is, no such output will be generated.- See Also:
OSCommands.appendable
,OSCommands.cmdOrCmdAndOutput
,OSCommands.printCmdAppendable
,OSCommands(Appendable, boolean, Appendable)
- Code:
- Exact Constructor Body:
super(appendable, cmdOrCmdAndOutput, printCmdAppendable);
-
Shell
public Shell(java.lang.Appendable appendable, boolean cmdOrCmdAndOutput, java.lang.Appendable printCmdAppendable, java.lang.Appendable standardOutput, java.lang.Appendable errorOutput)
Constructor that allows for assigning all four text-collectingAppendable's
. Please review the documentation for each of these fields to understand better how theseAppendable's
may be used.
NOTE: Any of theseAppendable's
may be assigned null, and if they are, they are simply ignored.NullPointerException
won't throw, and the relevant output text that would normally be appended to it, will simply not be appended.
Description copied in entirety from:OSCommands(Appendable, boolean, Appendable, Appendable, Appendable)
- Parameters:
appendable
- This parameter's reference is assigned directly to theOSCommands
field:appendable
. To clearly understand the use of this field, please review the documentation linked for that field. To summarize, thejava.lang.Appendable
that is synonymously namedappendable
simply collects all output text generated by a processes as it executes, and sends it to the reference'sappend(...)
method. This text will include that sent to BOTHStandard-Output
AND text sent toError-Output
. The text that is printed is transmitted in the order it is received from the reader-threads that read the underlying process' text-pipes.
By default this parameter is assignedSystem.out
. When this default value is used, it means that as the process executes, any and all text it prints is sent to the UNIX or MS-DOS Operating System Terminal Window.
This field may be assigned null, and when so it is just ignored. Assigning null toappendable
. will not produce aNullPointerException
.cmdOrCmdAndOutput
- Thisboolean
is assigned to theOSCommands
field namedcmdOrCmdAndOutput
.
Please review the documentation for that field to understand clearly the use of this parameter.printCmdAppendable
- Thisjava.lang.Appendable
allows for yet another output mechanism when executing operating system commands. The sole purpose of thisAppendable
is to print the process command, itself, as a JavaString
- exactly as it was issued to the operating system.
This allows a type of "Monitor Log" to store all commands being issued to the Operating-System, without having to include the full-text output that those process calls have produced. The value passed to this parameter is assigned to theOSCommands
field namedprintCmdAppendable
.
This parameter may be null, and if it is, no such output will be generated.standardOutput
- ThisAppendable
is assigned to the internalOSCommands
field:standardOutput
. ThisAppendabe
, as the name hopefully implies, allows a user to collect any / all text sent by the process toStandard-Output
.
Please review the documentation for that field to better understand it's use. Also, keep in mind that null may be passed to this parameter, and if / when it is the correspondingAppendable
field will simply be ignored during the process execution.errorOutput
- ThisAppendable
is assigned to the internalOSCommands
field:errorOutput
. ThisAppendabe
, as the name hopefully implies, allows a user to collect any / all text sent by the process toError-Output
.
Please review the documentation for that field to better understand it's use. Also, keep in mind that null may be passed to this parameter, and if / when it is the correspondingAppendable
field will simply be ignored during the process execution.- See Also:
OSCommands.appendable
,OSCommands.cmdOrCmdAndOutput
,OSCommands.printCmdAppendable
,OSCommands.standardOutput
,OSCommands.errorOutput
,OSCommands(Appendable, boolean, Appendable, Appendable, Appendable)
- Code:
- Exact Constructor Body:
super(appendable, cmdOrCmdAndOutput, printCmdAppendable, standardOutput, errorOutput);
-
Shell
public Shell(java.lang.Appendable standardOutput, java.lang.Appendable errorOutput)
This constructor retains all default values for the internal fields of this class, except for the twoOSCommands
Appendable
fields listed, namely:standardOutput
anderrorOutput
Description copied in entirety from:OSCommands(Appendable, Appendable)
- Parameters:
standardOutput
- ThisAppendable
is assigned to the internalOSCommands
field:standardOutput
. ThisAppendabe
, as the name hopefully implies, allows a user to collect any / all text sent by the process toStandard-Output
.
Please review the documentation for that field to better understand it's use. Also, keep in mind that null may be passed to this parameter, and if / when it is the correspondingAppendable
field will simply be ignored during the process execution.errorOutput
- ThisAppendable
is assigned to the internalOSCommands
field:errorOutput
. ThisAppendabe
, as the name hopefully implies, allows a user to collect any / all text sent by the process toError-Output
.
Please review the documentation for that field to better understand it's use. Also, keep in mind that null may be passed to this parameter, and if / when it is the correspondingAppendable
field will simply be ignored during the process execution.- See Also:
OSCommands.standardOutput
,OSCommands.errorOutput
,OSCommands(Appendable, Appendable)
- Code:
- Exact Constructor Body:
super(standardOutput, errorOutput);
-
-
Method Detail
-
clone
public Shell clone()
Creates a clone of'this'
instance. Though unlikely of much use, this could conceivably have some function if similar, but non-identical, output mechanisms were being used.- Specified by:
clone
in classOSCommands
- Returns:
- An exact copy of
'this'
instance ofShell.XL
- one in which all outputAppendable's
have had their references copied into the new instance. - Code:
- Exact Method Body:
return new Shell( this.appendable, this.cmdOrCmdAndOutput, this.printCmdAppendable, this.standardOutput, this.errorOutput );
-
CP
public OSResponse CP(java.lang.String src, java.lang.String target) throws java.io.IOException
UNIX Shell Command:Copy
UNIX or DOS Shell Command:
$ cp <src> <target>- Parameters:
src
- UNIX/Linux/BASH-Shell'cp'
command's "source" argumenttarget
- The'cp'
command "target" argument- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = { "cp", src, target }; return printAndRun(command);
-
CP
public OSResponse CP(java.util.Vector<java.lang.String> src, java.lang.String target) throws java.io.IOException
UNIX Shell Command:Copy
UNIX or DOS Shell Command:
$ cp <src.elementAt(0)> <src.elementAt(1)> ... <src.elementAt(src.size()-1)> <target>- Parameters:
src
- This may be a list of files to be copied to a target directorytarget
- This is the target directory for the files listed.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = new String[src.size() + 2]; command[0] = "cp"; command[src.size() + 1] = target; for (int i=0; i < src.size(); i++) command[1 + i] = src.elementAt(i); return printAndRun(command);
-
CP
public OSResponse CP(java.lang.String[] src, java.lang.String target) throws java.io.IOException
UNIX Shell Command:Copy
UNIX or DOS Shell Command:
$ cp <src[0]> <src[1]> ... <src[src.length-1]> <target>- Parameters:
src
- This may be a list of files to be copied to a target directorytarget
- This is the target directory for the files listed.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = new String[src.length + 2]; command[0] = "cp"; command[src.length + 1] = target; for (int i=0; i < src.length; i++) command[1 + i] = src[i]; return printAndRun(command);
-
LS
public OSResponse LS(java.lang.String fileOrDir) throws java.io.IOException
UNIX Shell Command:List
UNIX or DOS Shell Command:
$ ls <fileOrDir>- Parameters:
fileOrDir
- This is the file OR directory to be searched.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = { "ls", fileOrDir }; return printAndRun(command);
-
LS
public OSResponse LS(java.lang.String fileOrDir, java.lang.String switches) throws java.io.IOException
UNIX Shell Command:List
UNIX or DOS Shell Command:
$ ls <switches> <fileOrDir>- Parameters:
fileOrDir
- This is the file OR directory to be searched.switches
- These are switches that are added to the command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = { "ls", switches, fileOrDir }; return printAndRun(command);
-
MV
public OSResponse MV(java.lang.String src, java.lang.String target) throws java.io.IOException
UNIX Shell Command:Move
UNIX or DOS Shell Command:
$ mv <src> <target>- Parameters:
src
- The firstString
in a typical UNIX'move'
command. It is the "source file"target
- The secondString
for a "move." This is the destination or target.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = { "mv", src, target }; return printAndRun(command);
-
MV
public OSResponse MV(java.util.Vector<java.lang.String> src, java.lang.String target) throws java.io.IOException
UNIX Shell Command:Move
UNIX or DOS Shell Command:
$ mv <src.elementAt(0)> <src.elementAt(1)> ... <src.elementAt(src.size()-1)> <target>- Parameters:
src
- The firstString
in a typical UNIX'move'
command. It is the "source file" - In this method, it is a list of files and expressions saved as aVector
.target
- The secondString
for a'move'
UNIX command, and it is the target destination of the source-file.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = new String[src.size() + 2]; command[0] = "mv"; command[src.size() + 1] = target; for (int i=0; i < src.size(); i++) command[1 + i] = src.elementAt(i); return printAndRun(command);
-
MV
public OSResponse MV(java.lang.String[] src, java.lang.String target) throws java.io.IOException
UNIX Shell Command:Move
UNIX or DOS Shell Command:
$ mv <src[0]> <src[1]> ... <src[src.length-1]> <target>- Parameters:
src
- The firstString
in a typical UNIX'move'
command. It is the "source file" - In this method, it is a list of files and expressions saved as an array.target
- The secondString
for a UNIX'move'
command, and it is the target destination- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = new String[src.length + 2]; command[0] = "mv"; command[src.length + 1] = target; for (int i=0; i < src.length; i++) command[1 + i] = src[i]; return printAndRun(command);
-
RM
public OSResponse RM(java.lang.String s1) throws java.io.IOException
UNIX Shell Command:Remove
UNIX or DOS Shell Command:
$ rm <s1>- Parameters:
s1
- The item to be removed, using a UNIX operating-system command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = { "rm", s1 }; return printAndRun(command);
-
RM
public OSResponse RM(java.lang.String[] sArr) throws java.io.IOException
UNIX Shell Command:Remove
UNIX or DOS Shell Command:
$ rm <sArr[0]> <sArr[1]> ... <sArr[sArr.length-1]>- Parameters:
sArr
- AnString[] array
which is added to the end of this UNIX command. These will be the item(s) removed by the UNIX'RM'
command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = new String[sArr.length + 1]; command[0] = "rm"; for (int i=0; i < sArr.length; i++) command[i + 1] = sArr[i]; return printAndRun(command);
-
RM
public OSResponse RM(java.util.Vector<java.lang.String> v) throws java.io.IOException
UNIX Shell Command:Remove
UNIX or DOS Shell Command:
$ rm <src.elementAt(0)> <src.elementAt(1)> ... <src.elementAt(src.size()-1)>- Parameters:
v
- AVector<String>
that contains command-line-parameters which are added, sequentially, to the end of this UNIX command. TheString's
in thisVector
are the item(s) to be removed by the UNIX'RM'
command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = new String[v.size() + 1]; command[0] = "rm"; for (int i=0; i < v.size(); i++) command[i + 1] = v.elementAt(i); return printAndRun(command);
-
RM
public OSResponse RM(java.lang.String s1, java.lang.String switches) throws java.io.IOException
UNIX Shell Command:Remove
UNIX or DOS Shell Command:
$ rm <switches> <s1>- Parameters:
s1
- A file or directory parameter passed to'RM'
switches
- These are switches (for-instance:-R
, recursive).- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = { "rm", switches, s1 }; return printAndRun(command);
-
TAR
public OSResponse TAR(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:tar
UNIX or DOS Shell Command:
$ tar <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("tar", args);
-
JAR
public OSResponse JAR(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:jar
UNIX or DOS Shell Command:
$ jar <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("jar", args);
-
GREP
public OSResponse GREP(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:grep
UNIX or DOS Shell Command:
$ grep <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("grep", args);
-
FIND
public OSResponse FIND(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:find
UNIX or DOS Shell Command:
$ find <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("find", args);
-
DU
public OSResponse DU(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:du
UNIX or DOS Shell Command:
$ du <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("du", args);
-
DF
public OSResponse DF(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:df
UNIX or DOS Shell Command:
$ df <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("df", args);
-
SED
public OSResponse SED(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:sed
UNIX or DOS Shell Command:
$ sed <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("sed", args);
-
WHATIS
public OSResponse WHATIS(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:whatis
UNIX or DOS Shell Command:
$ whatis <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("whatis", args);
-
WHEREIS
public OSResponse WHEREIS(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:whereis
UNIX or DOS Shell Command:
$ whereis <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("whereis", args);
-
VMSTAT
public OSResponse VMSTAT(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:vmstat
UNIX or DOS Shell Command:
$ vmstat <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("vmstat", args);
-
PS
public OSResponse PS(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:ps
UNIX or DOS Shell Command:
$ ps <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("ps", args);
-
DIFF
public OSResponse DIFF(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:diff
UNIX or DOS Shell Command:
$ diff <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("diff", args);
-
CMP
public OSResponse CMP(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:cmp
UNIX or DOS Shell Command:
$ cmp <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("CMP", args);
-
FREE
public OSResponse FREE(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:free
UNIX or DOS Shell Command:
$ free <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("free", args);
-
CHOWN
public OSResponse CHOWN(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:chown
UNIX or DOS Shell Command:
$ chown <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("chown", args);
-
CHMOD
public OSResponse CHMOD(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:chmod
UNIX or DOS Shell Command:
$ chmod <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("chmod", args);
-
UNZIP
public OSResponse UNZIP(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:unzip
UNIX or DOS Shell Command:
$ unzip <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("unzip", args);
-
GZIP
public OSResponse GZIP(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:gzip
UNIX or DOS Shell Command:
$ gzip <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("gzip", args);
-
SORT
public OSResponse SORT(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:sort
UNIX or DOS Shell Command:
$ sort <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("sort", args);
-
JAVAC
public OSResponse JAVAC(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:javac
UNIX or DOS Shell Command:
$ javac <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("javac", args);
-
JAVADOC
public OSResponse JAVADOC(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:javadoc
UNIX or DOS Shell Command:
$ javadoc <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("javadoc", args);
-
JAVA
public OSResponse JAVA(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:java
UNIX or DOS Shell Command:
$ java <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("java", args);
-
TIME
public OSResponse TIME(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:time
UNIX or DOS Shell Command:
$ time <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("java", args);
-
DATE
public OSResponse DATE(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:date
UNIX or DOS Shell Command:
$ date <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("java", args);
-
TRACEROUTE
public OSResponse TRACEROUTE(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:traceroute
UNIX or DOS Shell Command:
$ traceroute <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("traceroute", args);
-
FSCK
public OSResponse FSCK(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:fsck
UNIX or DOS Shell Command:
$ fsck <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("fsck", args);
-
NSLOOKUP
public OSResponse NSLOOKUP(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:nslookup
UNIX or DOS Shell Command:
$ nslookup <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("nslookup", args);
-
PING
public OSResponse PING(java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command:ping
UNIX or DOS Shell Command:
$ ping <args[0]> <args[1]> ... <args[args.length-1]>- Parameters:
args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE("ping", args);
-
COMMAND
public OSResponse COMMAND(java.lang.String COMMAND_NAME, java.lang.String... args) throws java.io.IOException
Runs theUNIX / BASH / LINUX 'shell'
command named by the input parameterCOMMAND_NAME
.
UNIX or DOS Shell Command:
$ COMMAND_NAME <args[0]> <args[1]> ... <args[args.length-1]>
Other Commands:
Using the COMMAND method provides a simple way for the user to invoke UNIX / Shell commands which are not listed or provided by classShell
(this class). It ought to be of note, that the primary reason for writing this class is to merely provide explanation, and additional example use of Java's API. for executing Shell Processes from within the Java Virtual Machine. Though quite a bit of effort was spent writing wrappers that read all of the output stream generated when invoking a process, these are for the large part, just wrapper methods that surround the already existing Javajava.lang.Runtime
andjava.lang.Process
classes.
For example, the UNIX command'cron'
- a task scheduler that was commonly used way back - does not actually have a method listed in this class. If a situation where the'cron'
command suddenly needed to be called from within the JRE, simply invoking this method passing the value"cron"
to input parameter'COMMAND_NAME'
(along with any required parameters to input-parameter'args'
) would be how to do this.
Example:
// Build an instance. The default / zero-argument constructor will initialize all output logs // to null - except the primary output Appendable. Output is sent to System.out Shell shell = new Shell(); // This should start the cron service, and log level 1 // Make sure the necessary configuration files have been created. shell.COMMAND("cron", "-L", "1");
Any number of other UNIX / Shell commands not available through the methods in this class may be invoked using this simpleCOMMAND
method.- Parameters:
COMMAND_NAME
- This is the name of any UNIX command not already listed inside this class.args
- Any set of switches and/or arguments to this BASH command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are problems while invoking the operating-system command- Code:
- Exact Method Body:
return ARGS_PLUS_ONE(COMMAND_NAME, args);
-
-