org.ijsberg.iglu.util.execution
Class CommandShell

java.lang.Object
  extended by org.ijsberg.iglu.util.execution.CommandShell
All Implemented Interfaces:
Transceiver, Transmitter

public class CommandShell
extends Object
implements Transceiver

Tries to start a command shell in the OS and establishes standard in- and output.

Input may be passed by invoking transmit(). Output can be obtained by passing registering a receiver by invoking open(Listener).


Nested Class Summary
static class CommandShell.NewLineFilter
           
 
Constructor Summary
CommandShell(String[] shellCommandArray, File workingDir)
           
CommandShell(String[] shellCommandArray, String[] alternativeEnvVars, File workingDir)
           
CommandShell(String shellCommand, File workingDir)
           
CommandShell(String shellCommand, String[] alternativeEnvVars, File workingDir)
           
 
Method Summary
static int available()
           
 void close()
           
static int execute(String[] commandArray, String[] alternativeEnvVars, File workingDir, Receiver outputReceiver)
          execute particular command
static int execute(String command, File dir)
           
static int execute(String command, String[] envVars, File dir)
          Blindly invokes a shell command on Windows or Unix systems.
static void executeRecursive(String command, String rootdir)
           
 boolean isClosed()
           
static void main(String[] args)
          Runs test dialog.
 Receiver open(Receiver receiver)
          Opens permanent shell
static Object read()
           
 void transmit(Object message)
          Transmits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandShell

public CommandShell(String[] shellCommandArray,
                    String[] alternativeEnvVars,
                    File workingDir)
Parameters:
shellCommandArray -
alternativeEnvVars -
workingDir -
See Also:
exec()

CommandShell

public CommandShell(String shellCommand,
                    String[] alternativeEnvVars,
                    File workingDir)
Parameters:
shellCommand -
alternativeEnvVars -
workingDir -

CommandShell

public CommandShell(String shellCommand,
                    File workingDir)
Parameters:
shellCommand -
workingDir -

CommandShell

public CommandShell(String[] shellCommandArray,
                    File workingDir)
Parameters:
shellCommandArray -
workingDir -
Method Detail

transmit

public void transmit(Object message)
Transmits

Specified by:
transmit in interface Transmitter
Parameters:
message -

close

public void close()
Specified by:
close in interface Transmitter

isClosed

public boolean isClosed()
Specified by:
isClosed in interface Transmitter
Returns:

available

public static int available()
Returns:

read

public static Object read()
Returns:

open

public Receiver open(Receiver receiver)
Opens permanent shell

Specified by:
open in interface Transceiver
Parameters:
receiver -
Returns:

execute

public static int execute(String[] commandArray,
                          String[] alternativeEnvVars,
                          File workingDir,
                          Receiver outputReceiver)
                   throws IOException
execute particular command

Returns:
Throws:
IOException

execute

public static int execute(String command,
                          File dir)
                   throws IOException
Parameters:
command -
dir -
Returns:
Throws:
IOException

execute

public static int execute(String command,
                          String[] envVars,
                          File dir)
                   throws IOException
Blindly invokes a shell command on Windows or Unix systems. Note: this command will hang if user input is required.

Parameters:
command -
dir -
Returns:
status code
Throws:
IOException

executeRecursive

public static void executeRecursive(String command,
                                    String rootdir)
                             throws IOException
Parameters:
command -
rootdir -
Throws:
IOException

main

public static void main(String[] args)
Runs test dialog.

Parameters:
args -


Copyright © 2011. All Rights Reserved.