source: other-projects/trunk/gs3-release-maker/tasks/sshtaskdef/src/mindbright/ssh/SSHCaptureConsole.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.4 KB
Line 
1/******************************************************************************
2 *
3 * Copyright (c) 1998,99 by Mindbright Technology AB, Stockholm, Sweden.
4 * www.mindbright.se, [email protected]
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 *****************************************************************************
17 * $Author: mats $
18 * $Date: 1999/10/21 07:21:40 $
19 * $Name: rel1-2-1 $
20 *****************************************************************************/
21package mindbright.ssh;
22
23import java.io.*;
24
25import mindbright.terminal.Terminal;
26import mindbright.security.Cipher;
27
28public final class SSHCaptureConsole implements SSHConsole {
29
30 SSHConsole realConsole;
31 OutputStream captureOut;
32 SSHClient client;
33
34 public SSHCaptureConsole(SSHClient client, OutputStream captureOut) {
35 this.realConsole = client.getConsole();
36 this.captureOut = captureOut;
37 this.client = client;
38 client.setConsole(this);
39 }
40
41 public Terminal getTerminal() {
42 return realConsole.getTerminal();
43 }
44
45 public void stdoutWriteString(byte[] str) {
46 capture(new String(str));
47 realConsole.stdoutWriteString(str);
48 }
49
50 public void stderrWriteString(byte[] str) {
51 capture(new String(str));
52 realConsole.stderrWriteString(str);
53 }
54
55 public void print(String str) {
56 capture(str);
57 realConsole.print(str);
58 }
59
60 public void println(String str) {
61 capture(str);
62 realConsole.println(str);
63 }
64
65 void capture(String str) {
66 try {
67 captureOut.write(str.getBytes());
68 captureOut.flush();
69 } catch (IOException e) {
70 }
71 }
72
73 public void endCapture() {
74 client.setConsole(realConsole);
75 try {
76 captureOut.close();
77 } catch (IOException e) {
78 }
79 }
80
81 public void serverConnect(SSHChannelController controller, Cipher sndCipher) {
82 realConsole.serverConnect(controller, sndCipher);
83 }
84
85 public void serverDisconnect(String reason) {
86 realConsole.serverDisconnect(reason);
87 }
88
89}
Note: See TracBrowser for help on using the repository browser.