gov.bnl.star.offline.scheduler.util
Class CSHCommandLineTask

java.lang.Object
  extended by java.lang.Thread
      extended by gov.bnl.star.offline.scheduler.util.Task
          extended by gov.bnl.star.offline.scheduler.util.CSHCommandLineTask
All Implemented Interfaces:
java.lang.Runnable

public class CSHCommandLineTask
extends Task

A command line task.

Version:
$Revision: 1.13 $ $Date: 2006/11/21 00:41:29 $
Author:
Gabriele Carcassi

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class gov.bnl.star.offline.scheduler.util.Task
exitStatus
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CSHCommandLineTask(java.lang.String commandLine)
          A new command line task.
CSHCommandLineTask(java.lang.String commandLine, boolean bufferCommandOutput)
          A new command line task.
CSHCommandLineTask(java.lang.String commandLine, boolean bufferCommandError, int msTimeout)
           
CSHCommandLineTask(java.lang.String commandLine, int msTimeout)
          A new command line task with a timeout.
CSHCommandLineTask(java.lang.String commandLine, int msTimeout, boolean bufferCommandOutput)
           
 
Method Summary
 void destroy()
           
 java.lang.String getOutput()
          Returns all the output of the command.
 java.io.BufferedReader getOutputReader()
          Returns the output of the command
static void main(java.lang.String[] args)
           
 void run()
          Calls the external command.
 
Methods inherited from class gov.bnl.star.offline.scheduler.util.Task
execute, getExitStatus
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CSHCommandLineTask

public CSHCommandLineTask(java.lang.String commandLine)
A new command line task.

WARNING: the parsing of the command line won't be what you would have while executing at a UNIX prompt. The command line won't be passed to the shell, that is why it may have different result. For example, wildcards are usually resolved by the shell, and not by the program themselves.

Parameters:
commandLine - the command line to be executed

CSHCommandLineTask

public CSHCommandLineTask(java.lang.String commandLine,
                          boolean bufferCommandOutput)
A new command line task. This allows you to buffer the output of the command. You can retrieve the ouput with getOutput or getOutputReader

WARNING: the parsing of the command line won't be what you would have while executing at a UNIX prompt. The command line won't be passed to the shell, that is why it may have different result. For example, wildcards are usually resolved by the shell, and not by the program themselves.

Parameters:
commandLine - the command line to be executed
bufferCommandOutput - if true, the output will be buffered

CSHCommandLineTask

public CSHCommandLineTask(java.lang.String commandLine,
                          int msTimeout)
A new command line task with a timeout. The command will be aborted if the process doesn't return before the timeout.

WARNING: the parsing of the command line won't be what you would have while executing at a UNIX prompt. The command line won't be passed to the shell, that is why it may have different result. For example, wildcards are usually resolved by the shell, and not by the program themselves.

Parameters:
commandLine -
msTimeout -

CSHCommandLineTask

public CSHCommandLineTask(java.lang.String commandLine,
                          int msTimeout,
                          boolean bufferCommandOutput)

CSHCommandLineTask

public CSHCommandLineTask(java.lang.String commandLine,
                          boolean bufferCommandError,
                          int msTimeout)
Method Detail

run

public void run()
Calls the external command. Don't use this directly, or your task won't be executed in a separate thread. Use execute instead.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

destroy

public void destroy()
Overrides:
destroy in class java.lang.Thread

getOutput

public java.lang.String getOutput()
Returns all the output of the command.

Returns:
the output of the command line

getOutputReader

public java.io.BufferedReader getOutputReader()
Returns the output of the command

Returns:
the output of the command

main

public static void main(java.lang.String[] args)
Parameters:
args - the command line arguments


Copyright © 2002-2004 STAR collaboration - Brookhaven National Laboratory. All Rights Reserved.