1
/* -*-mode:java; c-basic-offset:2; -*- */
3
Copyright (c) 2002,2003,2004 ymnk, JCraft,Inc. All rights reserved.
5
Redistribution and use in source and binary forms, with or without
6
modification, are permitted provided that the following conditions are met:
8
1. Redistributions of source code must retain the above copyright notice,
9
this list of conditions and the following disclaimer.
11
2. Redistributions in binary form must reproduce the above copyright
12
notice, this list of conditions and the following disclaimer in
13
the documentation and/or other materials provided with the distribution.
15
3. The names of the authors may not be used to endorse or promote products
16
derived from this software without specific prior written permission.
18
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
19
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
21
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
22
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
package com.jcraft.jsch;
34
public class ChannelExec extends ChannelSession{
35
boolean xforwading=false;
40
type="session".getBytes();
44
public void setXForwarding(boolean foo){
51
request=new RequestX11();
52
request.request(session, this);
54
request=new RequestExec(command);
55
//((RequestExec)request).setCommand(command);
56
request.request(session, this);
60
//(new Thread(this)).start();
61
thread=new Thread(this);
62
((Thread)thread).start();
64
public void setCommand(String foo){ command=foo;}
66
io.setInputStream(session.in);
67
io.setOutputStream(session.out);
69
public void finalize() throws java.lang.Throwable{
70
((Thread)thread).interrupt();
75
//System.out.println(this+":run >");
77
Buffer buf=new Buffer();
78
// Buffer buf=new Buffer(lmpsize);
79
Packet packet=new Packet(buf);
82
while(isConnected() &&
86
i=io.in.read(buf.buffer, 14, buf.buffer.length-14);
94
buf.putByte((byte)Session.SSH_MSG_CHANNEL_DATA);
95
buf.putInt(recipient);
98
session.write(packet, this, i);
102
//System.out.println("# ChannelExec.run");
103
//e.printStackTrace();
106
//System.out.println(this+":run <");
109
public void setErrStream(java.io.OutputStream out){
110
setExtOutputStream(out);
112
public java.io.InputStream getErrStream() throws java.io.IOException {
113
return getExtInputStream();