ChannelExec.java
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 package com.jcraft.jsch;
00031
00032 import java.util.*;
00033
00046 public class ChannelExec extends ChannelSession{
00047
00048 byte[] command=new byte[0];
00049
00050
00051 public void start() throws JSchException{
00052 Session _session=getSession();
00053 try{
00054 sendRequests();
00055 Request request=new RequestExec(command);
00056 request.request(_session, this);
00057 }
00058 catch(Exception e){
00059 if(e instanceof JSchException) throw (JSchException)e;
00060 if(e instanceof Throwable)
00061 throw new JSchException("ChannelExec", (Throwable)e);
00062 throw new JSchException("ChannelExec");
00063 }
00064
00065 if(io.in!=null){
00066 thread=new Thread(this);
00067 thread.setName("Exec thread "+_session.getHost());
00068 if(_session.daemon_thread){
00069 thread.setDaemon(_session.daemon_thread);
00070 }
00071 thread.start();
00072 }
00073 }
00074
00081 public void setCommand(String command){
00082 this.command=Util.str2byte(command);
00083 }
00088 public void setCommand(byte[] command){
00089 this.command=command;
00090 }
00091
00092 void init() throws JSchException {
00093 io.setInputStream(getSession().in);
00094 io.setOutputStream(getSession().out);
00095 }
00096
00103 public void setErrStream(java.io.OutputStream out){
00104 setExtOutputStream(out);
00105 }
00106
00114 public void setErrStream(java.io.OutputStream out, boolean dontclose){
00115 setExtOutputStream(out, dontclose);
00116 }
00117
00124 public java.io.InputStream getErrStream() throws java.io.IOException {
00125 return getExtInputStream();
00126 }
00127 }