com.jcraft.jsch
Class ChannelExec

java.lang.Object
  extended by com.jcraft.jsch.Channel
      extended by com.jcraft.jsch.ChannelExec
All Implemented Interfaces:
Runnable

public class ChannelExec
extends Channel

A channel connected to a remotely executing program. Such a channel is created with:

    ChannelExec channel = (ChannelExec)session.openChannel("exec");
    channel.setCommand(cmd);
  

See Also:
RFC 4254, section 6.5. Starting a Shell or a Command

Field Summary
protected  boolean agent_forwarding
           
protected  Hashtable env
           
protected  boolean pty
           
protected  int tcol
           
protected  byte[] terminal_mode
           
protected  int thp
           
protected  int trow
           
protected  String ttype
           
protected  int twp
           
protected  boolean xforwading
           
 
Fields inherited from class com.jcraft.jsch.Channel
type
 
Constructor Summary
ChannelExec()
           
 
Method Summary
 InputStream getErrStream()
          Gets the error stream.
 void run()
          not to be called by the application.
protected  void sendRequests()
          creates and sends all requests indicated by the properties agentForwarding, xForwarding, pty (and ptyType) and env.
 void setAgentForwarding(boolean enable)
          Enable the agent forwarding.
 void setCommand(byte[] command)
          sets the command to be executed.
 void setCommand(String command)
          sets the command to be executed.
 void setEnv(byte[] name, byte[] value)
          Set the environment variable.
 void setEnv(Hashtable env)
          Deprecated. Use setEnv(String, String) or setEnv(byte[], byte[]) instead.
 void setEnv(String name, String value)
          Set the environment variable.
 void setErrStream(OutputStream out)
          Sets the error stream.
 void setErrStream(OutputStream out, boolean dontclose)
          Sets the error stream.
 void setPty(boolean enable)
          Allocate a Pseudo-Terminal.
 void setPtySize(int col, int row, int wp, int hp)
          Change the window dimension interactively.
 void setPtyType(String ttype)
          Set the terminal type.
 void setPtyType(String ttype, int col, int row, int wp, int hp)
          Set the terminal type.
 void setTerminalMode(byte[] terminal_mode)
          Set the terminal mode.
 void setXForwarding(boolean enable)
          Enable the X11 forwarding.
 void start()
          Not to be called externally.
 
Methods inherited from class com.jcraft.jsch.Channel
connect, connect, disconnect, getExitStatus, getExtInputStream, getId, getInputStream, getOutputStream, getSession, isClosed, isConnected, isEOF, sendOpenConfirmation, sendOpenFailure, sendSignal, setExtOutputStream, setExtOutputStream, setInputStream, setInputStream, setOutputStream, setOutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agent_forwarding

protected boolean agent_forwarding

xforwading

protected boolean xforwading

env

protected Hashtable env

pty

protected boolean pty

ttype

protected String ttype

tcol

protected int tcol

trow

protected int trow

twp

protected int twp

thp

protected int thp

terminal_mode

protected byte[] terminal_mode
Constructor Detail

ChannelExec

public ChannelExec()
Method Detail

start

public void start()
           throws JSchException
Description copied from class: Channel
Not to be called externally. This method is called by Channel.connect(int) when the connection is established. This implementation here does nothing, but it is overridden in some subclasses.

Overrides:
start in class Channel
Throws:
JSchException

setCommand

public void setCommand(String command)
sets the command to be executed.

Parameters:
command - the command to be executed. We will use the platform's default encoding to encode this string.

setCommand

public void setCommand(byte[] command)
sets the command to be executed.

Parameters:
command - the command to be executed.

setErrStream

public void setErrStream(OutputStream out)
Sets the error stream. The standard error output of the remote process will be sent to this stream. The stream will be closed on Channel.disconnect(com.jcraft.jsch.Session).


setErrStream

public void setErrStream(OutputStream out,
                         boolean dontclose)
Sets the error stream. The standard error output of the remote process will be sent to this stream.

Parameters:
dontclose - if true, we do not close the stream on Channel.disconnect(com.jcraft.jsch.Session).

getErrStream

public InputStream getErrStream()
                         throws IOException
Gets the error stream. The standard error output of the remote process can be read from this stream. This method is a polling alternative to setErrStream(java.io.OutputStream).

Throws:
IOException

setAgentForwarding

public void setAgentForwarding(boolean enable)
Enable the agent forwarding.

Parameters:
enable -

setXForwarding

public void setXForwarding(boolean enable)
Enable the X11 forwarding.

Overrides:
setXForwarding in class Channel
Parameters:
enable -
See Also:
RFC4254 6.3.1. Requesting X11 Forwarding

setEnv

public void setEnv(Hashtable env)
Deprecated. Use setEnv(String, String) or setEnv(byte[], byte[]) instead.

See Also:
setEnv(String, String), setEnv(byte[], byte[])

setEnv

public void setEnv(String name,
                   String value)
Set the environment variable. If name and value are needed to be passed to the remote in your faivorite encoding,use setEnv(byte[], byte[]).

Parameters:
name - A name for environment variable.
value - A value for environment variable.
See Also:
RFC4254 6.4 Environment Variable Passing

setEnv

public void setEnv(byte[] name,
                   byte[] value)
Set the environment variable.

Parameters:
name - A name of environment variable.
value - A value of environment variable.
See Also:
setEnv(String, String), RFC4254 6.4 Environment Variable Passing

setPty

public void setPty(boolean enable)
Allocate a Pseudo-Terminal.

Parameters:
enable -
See Also:
RFC4254 6.2. Requesting a Pseudo-Terminal

setTerminalMode

public void setTerminalMode(byte[] terminal_mode)
Set the terminal mode.

Parameters:
terminal_mode -

setPtySize

public void setPtySize(int col,
                       int row,
                       int wp,
                       int hp)
Change the window dimension interactively.

Parameters:
col - terminal width, columns
row - terminal height, rows
wp - terminal width, pixels
hp - terminal height, pixels
See Also:
RFC4254 6.7. Window Dimension Change Message

setPtyType

public void setPtyType(String ttype)
Set the terminal type. This method is not effective after Channel#connect().

Parameters:
ttype - terminal type(for example, "vt100")
See Also:
setPtyType(String, int, int, int, int)

setPtyType

public void setPtyType(String ttype,
                       int col,
                       int row,
                       int wp,
                       int hp)
Set the terminal type. This method is not effective after Channel#connect().

Parameters:
ttype - terminal type(for example, "vt100")
col - terminal width, columns
row - terminal height, rows
wp - terminal width, pixels
hp - terminal height, pixels

sendRequests

protected void sendRequests()
                     throws Exception
creates and sends all requests indicated by the properties agentForwarding, xForwarding, pty (and ptyType) and env.

Throws:
Exception

run

public void run()
not to be called by the application. Runs the main data transfer loop.

Specified by:
run in interface Runnable
Overrides:
run in class Channel


This is a simplified version of the inofficial Javadoc created by PaĆ­lo Ebermann. Have a look at the official homepage.