00001 using System;
00002 using System.Net;
00003 using System.Net.Sockets;
00004 using System.IO;
00005 using Tamir.SharpSsh.java.lang;
00006
00007 namespace Tamir.SharpSsh.jsch
00008 {
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 public class ChannelExec : ChannelSession
00039 {
00040 bool xforwading=false;
00041 bool pty=false;
00042 String command="";
00043
00044
00045
00046
00047
00048
00049
00050 public override void setXForwarding(bool foo){ xforwading=foo; }
00051 public void setPty(bool foo){ pty=foo; }
00052 public override void start()
00053 {
00054 try
00055 {
00056 Request request;
00057
00058 if(xforwading)
00059 {
00060 request=new RequestX11();
00061 request.request(session, this);
00062 }
00063
00064 if(pty)
00065 {
00066 request=new RequestPtyReq();
00067 request.request(session, this);
00068 }
00069
00070 request=new RequestExec(command);
00071 request.request(session, this);
00072 }
00073 catch(Exception e)
00074 {
00075 throw new JSchException("ChannelExec");
00076 }
00077 thread=new Thread(this);
00078 thread.setName("Exec thread "+session.getHost());
00079 thread.start();
00080 }
00081 public void setCommand(String foo){ command=foo;}
00082 public override void init()
00083 {
00084 io.setInputStream(session.In);
00085 io.setOutputStream(session.Out);
00086 }
00087
00088 public void setErrStream(Stream Out)
00089 {
00090 setExtOutputStream(Out);
00091 }
00092 public Stream getErrStream()
00093 {
00094 return getExtInputStream();
00095 }
00096 }
00097
00098 }