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:
ClassOSCommandsis the parent class for all classes which invoke Operating-System Processes using the Java-Standardjava.lang.ProcessObject-Utility.OSCommandshas several constructors inherited by this class which allow a user to configure this class for sending its output in any number of ways toAppendableinstances / 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.
ClassOSResponsealso 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.java.lang.ProcessExtrasjava.lang.Processprovides several additional features that allow a user to redirect output, and collect-input to and from any number of additional sources, among others.Torello.Javatakes advantage of these withclass OSExtras. Copious documentation about this class is provided, explaining these features.
To specialize an Operating-System call with anOSExtrasinstance, 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 theNodeSearchpackage 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.Processallowing 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 else in theJava HTML JAR Libraryis, indeed, O/S Independent (adhering to 'WORA'), this class and all classes which extendOSCommandsare not! In fact, they are highly O/S dependent. The methods in these classes are actually just a set of hooks into native Operating System calls.This does mean that any invocation of these methods, when running in some other Operating System Environment, will just throw exceptions.
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.
Logging Output:
This class inheritsOSCommands, which exports fourAppendableConfiguration-Fields for collecting the output of the Operating-System Commands in this class. These fields are all nullable, meaning that when one of these fields are assigned null, no exceptions will throw. Instead, that particular logging feature will simply be deactivated.
The table below explains whatjava.lang.ProcessOutput-Text is collected by each of thepublicConfigurable-Fields exported by (parent-class)OSCommands. All four of these are declaredpublic& non-final, so they are easily configured - just assign them to anyjava.lang.Appendableof your choosing!.
Each of these four configuration-fields will log a slightly different variant of thejava.lang.Processobject's output-text.Configurable Field Logged-Text Description / Type outputAppendableThe text that is sent to this log is the unified text produced by reading the java.lang.Processinstance's Standard-Output Stream, and its Error-Output Stream. Both are sent, as best as possible, in the order that such text is received by the reader threads.commandStrAppendableThis log simply collects the actual command being issued to the Process-Object. The text sent to this log is nothing more than the joined text of input-command'sString[]-Array.standardOutputThis log collects all text that is sent to Standard-Output when a command is executed. errorOutputThis log collects all text that is sent to Error-Output when a command is executed.
Both Command & Output:
One common trick, in Java HTML, is to provide the sameAppendableto bothoutputAppendableandcommandStrAppendable, which allows for printing a command as it is being executed, and then subsequently, all of its output.
In the two examples below, an instance of this class is built such that BOTH the command as aStringAND the process' output are logged directly to the exact sameAppendable. Here, the most commonly usedAppendableof all,java.lang.System.out, is configured. Note that these two examples are identical, and (slightly) different ways to perform the exact same configurations:
// Use a constructor to build an instance of this class. // Both the Process-Output and the Command-as-a-String are printed to System.out Shell shell = new Shell(System.out, System.out, null, null);
// Again - System.out is assigned to both "outputAppendable" and "commandStrAppendable" // The code here is functionally identical to the code in the previous example. Shell shell = new Shell(); shell.outputAppendable = System.out; shell.commandStrAppendable = System.out;
Appendable Help-Reminder: The following table provides a small reminder & description for several of the common ways to provide a Java Appendable to any method (or field) which accepts anAppendabletype. This table is re-printed in a few locations throughout the Java-HTML Library whereAppendable'sare accepted.
This expects an implementation of Java'sjava.lang.Appendableinterface which allows for a wide range of options when logging intermediate messages.Class or Interface Instance Use & Purpose 'System.out'Sends text to the standard-out terminal Torello.Java.StorageWriterSends text to System.out, and saves it, internally.FileWriter, PrintWriter, StringWriterGeneral purpose java text-output classes FileOutputStream, PrintStreamMore general-purpose java text-output classes
Checked IOException:
TheAppendableinterface requires that the Checked-ExceptionIOExceptionbe caught when using itsappend(...)methods.- See Also:
OSCommands,OSResponse
Hi-Lited Source-Code:- View Here: Torello/Java/Shell.java
- Open New Browser-Tab: Torello/Java/Shell.java
File Size: 30,728 Bytes Line Count: 804 '\n' Characters Found
-
-
Field Summary
-
Fields inherited from class Torello.Java.OSCommands
commandStrAppendable, errorOutput, osExtras, outputAppendable, standardOutput
-
-
Constructor Summary
Constructors Modifier Constructor Shell()Shell(Appendable outputAppendable)Shell(Appendable standardOutput, Appendable errorOutput)Shell(Appendable outputAppendable, Appendable commandStrAppendable, Appendable standardOutput, Appendable errorOutput)protectedShell(Shell other)
-
Method Summary
Copy Files & Directories Modifier and Type Method OSResponseCP(String[] src, String target)OSResponseCP(String src, String target)OSResponseCP(Vector<String> src, String target)Move Files & Directories Modifier and Type Method OSResponseMV(String[] src, String target)OSResponseMV(String src, String target)OSResponseMV(Vector<String> src, String target)Removing Files & Directories Modifier and Type Method OSResponseRM(String s1)OSResponseRM(String[] sArr)OSResponseRM(String s1, String switches)OSResponseRM(Vector<String> v)Listing Files & Directories Modifier and Type Method OSResponseLS(String fileOrDir)OSResponseLS(String fileOrDir, String switches)Common UNIX Commands Modifier and Type Method OSResponseCHMOD(String... args)OSResponseCHOWN(String... args)OSResponseCMP(String... args)OSResponseDATE(String... args)OSResponseDF(String... args)OSResponseDIFF(String... args)OSResponseDU(String... args)OSResponseFIND(String... args)OSResponseFREE(String... args)OSResponseFSCK(String... args)OSResponseGREP(String... args)OSResponseGZIP(String... args)OSResponseJAR(String... args)OSResponseJAVA(String... args)OSResponseJAVAC(String... args)OSResponseJAVADOC(String... args)OSResponseNSLOOKUP(String... args)OSResponsePING(String... args)OSResponsePS(String... args)OSResponseSED(String... args)OSResponseSORT(String... args)OSResponseTAR(String... args)OSResponseTIME(String... args)OSResponseTRACEROUTE(String... args)OSResponseUNZIP(String... args)OSResponseVMSTAT(String... args)OSResponseWHATIS(String... args)OSResponseWHEREIS(String... args)Any UNIX Command Modifier and Type Method OSResponseCOMMAND(String COMMAND_NAME, String... args)Methods: interface java.lang.Cloneable Modifier and Type Method Shellclone()-
Methods inherited from class Torello.Java.OSCommands
printAndRun, toString
-
-
-
-
Constructor Detail
-
Shell
public Shell()
This constructor assigns default values to all of the output loggingAppendable's.
Note that all of them are assigned 'null' - meaing their output will not be logged - except for the primary outputAppendablefield.this.outputAppendable. This field is assignedSystem.out, meaning that all text output by a process will be sent to the terminal window.- Code:
- Exact Constructor Body:
super();
-
Shell
public Shell(java.lang.Appendable outputAppendable)
This constructor allows a user to assign an instanceAppendableto:appendable.
The first collects all text-output generated by the processes and prints it using theAppendable'sprinting methods. This includes text generated for BOTHStandard-OutputANDError-Output. This text is collected in real time as it is output by the underlying process.Assigning null: Any of this classAppendable'smay be assigned null. When anAppendableis assigned null, it is simply ignored.NullPointerExceptionwill not throw, and any output text that would be appended, isn't appended.- Parameters:
outputAppendable- This parameter's reference is assigned directly to theOSCommandsfield:appendable. To clearly understand the use of this field, please review the documentation linked for that field. To summarize, thejava.lang.Appendablethat is synonymously namedappendablesimply 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-OutputAND 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.- See Also:
OSCommands.outputAppendable- Code:
- Exact Constructor Body:
super(outputAppendable);
-
Shell
public Shell(java.lang.Appendable outputAppendable, java.lang.Appendable commandStrAppendable, 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'smay be used. There are links in the See-Also section, below.Assigning null: Any of this classAppendable'smay be assigned null. When anAppendableis assigned null, it is simply ignored.NullPointerExceptionwill not throw, and any output text that would be appended, isn't appended.- Parameters:
outputAppendable- This parameter's reference is assigned directly to theOSCommandsfield:appendable. To clearly understand the use of this field, please review the documentation linked for that field. To summarize, thejava.lang.Appendablethat is synonymously namedappendablesimply 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-OutputAND 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.commandStrAppendable- Thisjava.lang.Appendableallows for yet another output mechanism when executing operating system commands. The sole purpose of thisAppendableis 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 theOSCommandsfield namedprintCmdAppendable.This parameter may be null, and if it is, no such output will be generated.standardOutput- ThisAppendableis assigned to the internalOSCommandsfield: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 correspondingAppendablefield will simply be ignored during the process execution.errorOutput- ThisAppendableis assigned to the internalOSCommandsfield: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 correspondingAppendablefield will simply be ignored during the process execution.- See Also:
OSCommands.outputAppendable,OSCommands.commandStrAppendable,OSCommands.standardOutput,OSCommands.errorOutput- Code:
- Exact Constructor Body:
super(outputAppendable, commandStrAppendable, standardOutput, errorOutput);
-
Shell
public Shell(java.lang.Appendable standardOutput, java.lang.Appendable errorOutput)
This constructor assigns values to these internalAppendablefields:standardOutputanderrorOutputAssigning null: Any of this classAppendable'smay be assigned null. When anAppendableis assigned null, it is simply ignored.NullPointerExceptionwill not throw, and any output text that would be appended, isn't appended.- Parameters:
standardOutput- ThisAppendableis assigned to the internalOSCommandsfield: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 correspondingAppendablefield will simply be ignored during the process execution.errorOutput- ThisAppendableis assigned to the internalOSCommandsfield: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 correspondingAppendablefield will simply be ignored during the process execution.- See Also:
OSCommands.standardOutput,OSCommands.errorOutput- Code:
- Exact Constructor Body:
super(standardOutput, errorOutput);
-
Shell
-
-
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:
clonein classOSCommands- Returns:
- An exact copy of
'this'instance - one in which all outputAppendable'shave had their references copied into the new instance. - Code:
- Exact Method Body:
return new Shell(this);
-
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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 firstStringin a typical UNIX'move'command. It is the "source file"target- The secondStringfor a "move." This is the destination or target.- Returns:
- Returns an instance of
OSResponse. This response-Object(data-record) class holds fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 firstStringin 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 secondStringfor 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 firstStringin 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 secondStringfor a UNIX'move'command, and it is the target destination- Returns:
- Returns an instance of
OSResponse. This response-Object(data-record) class holds fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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[] arraywhich 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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'sin thisVectorare the item(s) to be removed by the UNIX'RM'command.- Returns:
- Returns an instance of
OSResponse. This response-Object(data-record) class holds fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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.Runtimeandjava.lang.Processclasses.
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 simpleCOMMANDmethod.- 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 fourpublic, finalfields:
① Processresponse-code
② Text sent toStandard-Output(as ajava.lang.String)
③ Text sent toError-Output(also as aString)
④ The original Command-String
ThisOSResponseinstance may be discarded without any effect onProcessExecution. It is only provided as a convenience in case more information is required about the results of theO/Scommand invocation.Process Status: Upon completion of this method, theOperating-System java.lang.Processis guaranteed to have run to completion (or to have failed and been interrupted). If the process was interrupted, theresponse-codewill indicate this using the valueINTERRUPTED - 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);
-
-