net.i2p.util

## Class ShellCommand

- java.lang.Object
- - net.i2p.util.ShellCommand

-     public class ShellCommand
      extends Object

  Passes a command to the OS shell for execution and manages the input and output.

  This class must be kept `gcj`-compatible.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ShellCommand()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `executeSilentAndWait(String[] commandArray)` Passes a command to the shell for execution.
    `boolean` | `executeSilentAndWaitTimed(String[] commandArray, int seconds)` Passes a command to the shell for execution.
    `boolean` | `executeSilentAndWaitTimed(String shellCommand, int seconds)` Passes a command to the shell for execution.
    `static void` | `main(String[] args)` Just does exec, this is NOT a test of ShellCommand.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ShellCommand

          public ShellCommand()

  - ### Method Detail

    - #### executeSilentAndWait

          public boolean executeSilentAndWait(String[] commandArray)

      Passes a command to the shell for execution. This method blocks until all of the command's resulting shell processes have completed. Any output produced by the executed command will not be displayed.
      Parameters:
        `commandArray` - The command for the shell to execute, as a String[]. See Runtime.exec(String[]) for more info.
      Returns:
        `true` if the spawned shell process returns an exit status of 0 (indicating success), else `false`.

    - #### executeSilentAndWaitTimed

          public boolean executeSilentAndWaitTimed(String[] commandArray,
                                                   int seconds)

      Passes a command to the shell for execution. This method blocks until all of the command's resulting shell processes have completed unless a specified number of seconds has elapsed first. Any output produced by the executed command will not be displayed.
      Parameters:
        `commandArray` - The command for the shell to execute, as a String[]. See Runtime.exec(String[]) for more info.
        `seconds` - The method will return `true` if this number of seconds elapses without the process returning an exit status. A value of `0` here disables waiting.
      Returns:
        `true` if the spawned shell process returns an exit status of 0 (indicating success), OR if the time expires, else `false`.

    - #### executeSilentAndWaitTimed

          public boolean executeSilentAndWaitTimed(String shellCommand,
                                                   int seconds)

      Passes a command to the shell for execution. This method blocks until all of the command's resulting shell processes have completed unless a specified number of seconds has elapsed first. Any output produced by the executed command will not be displayed. Warning, no good way to quote or escape spaces in arguments when shellCommand is a String. Use a String array for best results, especially on Windows.
      Parameters:
        `shellCommand` - The command for the shell to execute, as a String. You can't quote arguments successfully. See Runtime.exec(String) for more info.
        `seconds` - The method will return `true` if this number of seconds elapses without the process returning an exit status. A value of `0` here disables waiting.
      Returns:
        `true` if the spawned shell process returns an exit status of 0 (indicating success), OR if the time expires, else `false`.

    - #### main

          public static void main(String[] args)

      Just does exec, this is NOT a test of ShellCommand.