Package 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.- Author:
- hypercubus
-
-
Constructor Summary
Constructors Constructor Description ShellCommand()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
execute(String shellCommand)
Deprecated.unusedboolean
executeAndWait(String shellCommand)
Deprecated.unusedboolean
executeAndWaitTimed(String shellCommand, int seconds)
Deprecated.unusedvoid
executeSilent(String shellCommand)
Deprecated.unusedboolean
executeSilentAndWait(String shellCommand)
Deprecated.Use the String[] methodboolean
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.InputStream
getErrorStream()
Deprecated.unusedInputStream
getInputStream()
Deprecated.unusedOutputStream
getOutputStream()
Deprecated.unusedstatic void
main(String[] args)
Just does exec, this is NOT a test of ShellCommand.
-
-
-
Method Detail
-
execute
@Deprecated public void execute(String shellCommand)
Deprecated.unusedPasses a command to the shell for execution and returns immediately without waiting for an exit status. All output produced by the executed command will go toSTDOUT
andSTDERR
as appropriate, and can be read viagetOutputStream()
andgetErrorStream()
, respectively. Input can be passed to theSTDIN
of the shell process viagetInputStream()
. Warning, no good way to quote or escape spaces in arguments with this method.- Parameters:
shellCommand
- The command for the shell to execute.
-
executeAndWait
@Deprecated public boolean executeAndWait(String shellCommand)
Deprecated.unusedPasses a command to the shell for execution. This method blocks until all of the command's resulting shell processes have completed. All output produced by the executed command will go toSTDOUT
andSTDERR
as appropriate, and can be read viagetOutputStream()
andgetErrorStream()
, respectively. Input can be passed to theSTDIN
of the shell process viagetInputStream()
. Warning, no good way to quote or escape spaces in arguments with this method.- Parameters:
shellCommand
- The command for the shell to execute.- Returns:
true
if the spawned shell process returns an exit status of 0 (indicating success), elsefalse
.
-
executeAndWaitTimed
@Deprecated public boolean executeAndWaitTimed(String shellCommand, int seconds)
Deprecated.unusedPasses 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. All output produced by the executed command will go toSTDOUT
andSTDERR
as appropriate, and can be read viagetOutputStream()
andgetErrorStream()
, respectively. Input can be passed to theSTDIN
of the shell process viagetInputStream()
. Warning, no good way to quote or escape spaces in arguments with this method.- Parameters:
shellCommand
- The command for the shell to execute.seconds
- The method will returntrue
if this number of seconds elapses without the process returning an exit status. A value of0
here disables waiting.- Returns:
true
if the spawned shell process returns an exit status of 0 (indicating success), elsefalse
.
-
executeSilent
@Deprecated public void executeSilent(String shellCommand) throws IOException
Deprecated.unusedPasses a command to the shell for execution and returns immediately without waiting for an exit status. Any output produced by the executed command will not be displayed. Warning, no good way to quote or escape spaces in arguments with this method.- Parameters:
shellCommand
- The command for the shell to execute.- Throws:
IOException
-
executeSilentAndWait
@Deprecated public boolean executeSilentAndWait(String shellCommand)
Deprecated.Use the String[] methodPasses 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. Warning, no good way to quote or escape spaces in arguments with this method.- Parameters:
shellCommand
- The command for the shell to execute.- Returns:
true
if the spawned shell process returns an exit status of 0 (indicating success), elsefalse
.
-
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), elsefalse
.- Since:
- 0.9.38
-
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 returntrue
if this number of seconds elapses without the process returning an exit status. A value of0
here disables waiting.- Returns:
true
if the spawned shell process returns an exit status of 0 (indicating success), OR if the time expires, elsefalse
.
-
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 returntrue
if this number of seconds elapses without the process returning an exit status. A value of0
here disables waiting.- Returns:
true
if the spawned shell process returns an exit status of 0 (indicating success), OR if the time expires, elsefalse
.- Since:
- 0.8.3
-
getErrorStream
@Deprecated public InputStream getErrorStream()
Deprecated.unused
-
getInputStream
@Deprecated public InputStream getInputStream()
Deprecated.unused
-
getOutputStream
@Deprecated public OutputStream getOutputStream()
Deprecated.unused
-
main
public static void main(String[] args)
Just does exec, this is NOT a test of ShellCommand.
-
-