public SshHelper(string host, string username, string password) { this.host = host; JSch jsch = new JSch(); Session session = jsch.getSession(username, host, 22); session.setPassword(password); Hashtable config = new Hashtable(); config.Add("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); channel = (ChannelShell)session.openChannel("shell"); writer_po = new PipedOutputStream(); PipedInputStream writer_pi = new PipedInputStream(writer_po); PipedInputStream reader_pi = new PipedInputStream(); PipedOutputStream reader_po = new PipedOutputStream(reader_pi); reader = new StreamReader(reader_pi, Encoding.UTF8); channel.setInputStream(writer_pi); channel.setOutputStream(reader_po); channel.connect(); channel.setPtySize(132, 132, 1024, 768); }
/// <exception cref="System.IO.IOException"></exception> public override void Close() { if (this.@out != null) { [email protected](); } this.@out = null; }
public override void close() { if (Out != null) { Out.close(); } Out = null; }
public override void close() { if (Out != null) { this.Out.Close(); } Out = null; }
public _Thread_340(InternalLocalPushConnection _enclosing, Repository dst, PipedInputStream out_r, PipedOutputStream in_w, string baseArg1) : base(baseArg1) { this._enclosing = _enclosing; this.dst = dst; this.out_r = out_r; this.in_w = in_w; }
public virtual void SetUp() { @out = new PipedOutputStream(); @in = new PipedInputStream(@out); timer = new InterruptTimer(); @is = new TimeoutInputStream(@in, timer); @is.SetTimeout(timeout); }
public virtual void SetUp() { @out = new PipedOutputStream(); @in = new TimeoutOutputStreamTest.FullPipeInputStream(this, @out); timer = new InterruptTimer(); os = new TimeoutOutputStream(@out, timer); os.SetTimeout(timeout); }
/// <exception cref="System.IO.IOException"></exception> public PassiveInputStream(Channel _enclosing, PipedOutputStream @out, int size) : base(_enclosing) { this._enclosing = _enclosing; // public String toString(){ // return "Channel: type="+new String(type)+",id="+id+",recipient="+recipient+",window_size="+window_size+",packet_size="+packet_size; // } this.@out = @out; }
public RtcpDeinterleaver(InputStream inputStream) { mInputStream = inputStream; mPipedInputStream = new PipedInputStream(4096); try { mPipedOutputStream = new PipedOutputStream(mPipedInputStream); } catch (IOException e) {} mBuffer = new byte[1024]; new Thread(this).Start(); }
public virtual Stream getOutputStream() { var Out = new PipedOutputStream(); io.setInputStream(new PassiveInputStream(Out , 32 * 1024 ), false); // io.setInputStream(new PassiveInputStream(Out), false); return(Out); }
private void CheckOutput(string[] args, string pattern, TextWriter @out, Type clazz ) { ByteArrayOutputStream outBytes = new ByteArrayOutputStream(); try { PipedOutputStream pipeOut = new PipedOutputStream(); PipedInputStream pipeIn = new PipedInputStream(pipeOut, PipeBufferSize); if (@out == System.Console.Out) { Runtime.SetOut(new TextWriter(pipeOut)); } else { if (@out == System.Console.Error) { Runtime.SetErr(new TextWriter(pipeOut)); } } if (clazz == typeof(DelegationTokenFetcher)) { ExpectDelegationTokenFetcherExit(args); } else { if (clazz == typeof(JMXGet)) { ExpectJMXGetExit(args); } else { if (clazz == typeof(DFSAdmin)) { ExpectDfsAdminPrint(args); } } } pipeOut.Close(); ByteStreams.Copy(pipeIn, outBytes); pipeIn.Close(); NUnit.Framework.Assert.IsTrue(Sharpen.Runtime.GetStringForBytes(outBytes.ToByteArray ()).Contains(pattern)); } catch (Exception ex) { NUnit.Framework.Assert.Fail("checkOutput error " + ex); } }
/// <exception cref="NGit.Errors.TransportException"></exception> public InternalLocalFetchConnection(TransportLocal _enclosing) : base(_enclosing ) { this._enclosing = _enclosing; Repository dst; try { dst = new FileRepository(this._enclosing.remoteGitDir); } catch (IOException) { throw new TransportException(this.uri, JGitText.Get().notAGitDirectory); } PipedInputStream in_r; PipedOutputStream in_w; PipedInputStream out_r; PipedOutputStream out_w; try { in_r = new PipedInputStream(); in_w = new PipedOutputStream(in_r); out_r = new _PipedInputStream_193(); // The client (BasePackFetchConnection) can write // a huge burst before it reads again. We need to // force the buffer to be big enough, otherwise it // will deadlock both threads. out_w = new PipedOutputStream(out_r); } catch (IOException err) { dst.Close(); throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err); } this.worker = new _Thread_208(this, dst, out_r, in_w, "JGit-Upload-Pack"); // Client side of the pipes should report the problem. // Clients side will notice we went away, and report. // Ignore close failure, we probably crashed above. // Ignore close failure, we probably crashed above. this.worker.Start(); this.Init(in_r, out_w); this.ReadAdvertisedRefs(); }
/// <exception cref="System.Exception"/> private static bool CheckPrintAllValues(JMXGet jmx) { int size = 0; byte[] bytes = null; string pattern = "List of all the available keys:"; PipedOutputStream pipeOut = new PipedOutputStream(); PipedInputStream pipeIn = new PipedInputStream(pipeOut); Runtime.SetErr(new TextWriter(pipeOut)); jmx.PrintAllValues(); if ((size = pipeIn.Available()) != 0) { bytes = new byte[size]; pipeIn.Read(bytes, 0, bytes.Length); } pipeOut.Close(); pipeIn.Close(); return(bytes != null?Sharpen.Runtime.GetStringForBytes(bytes).Contains(pattern) : false); }
/// <exception cref="NGit.Errors.TransportException"></exception> public InternalLocalPushConnection(TransportLocal _enclosing) : base(_enclosing ) { this._enclosing = _enclosing; Repository dst; try { dst = new FileRepository(this._enclosing.remoteGitDir); } catch (IOException) { throw new TransportException(this.uri, JGitText.Get().notAGitDirectory); } PipedInputStream in_r; PipedOutputStream in_w; PipedInputStream out_r; PipedOutputStream out_w; try { in_r = new PipedInputStream(); in_w = new PipedOutputStream(in_r); out_r = new PipedInputStream(); out_w = new PipedOutputStream(out_r); } catch (IOException err) { dst.Close(); throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err); } this.worker = new _Thread_340(this, dst, out_r, in_w, "JGit-Receive-Pack"); // Client side of the pipes should report the problem. // Clients side will notice we went away, and report. // Ignore close failure, we probably crashed above. // Ignore close failure, we probably crashed above. this.worker.Start(); this.Init(in_r, out_w); this.ReadAdvertisedRefs(); }
/// <exception cref="System.Exception"/> protected internal virtual void VerifyJobPriority(string jobId, string priority, Configuration conf, CLI jc) { PipedInputStream pis = new PipedInputStream(); PipedOutputStream pos = new PipedOutputStream(pis); int exitCode = RunTool(conf, jc, new string[] { "-list", "all" }, pos); NUnit.Framework.Assert.AreEqual("Exit code", 0, exitCode); BufferedReader br = new BufferedReader(new InputStreamReader(pis)); string line; while ((line = br.ReadLine()) != null) { Log.Info("line = " + line); if (!line.Contains(jobId)) { continue; } NUnit.Framework.Assert.IsTrue(line.Contains(priority)); break; } pis.Close(); }
public PipedInputStream(PipedOutputStream prm1) { }
public PipedInputStream(PipedOutputStream prm1, int prm2) { }
public virtual void connect(PipedOutputStream prm1) { }
internal ChannelPipedInputStream(PipedOutputStream Out, int size) : base(Out) { m_buffer = new byte[size]; }
/** * Causes this piped input stream to be connected * to the piped output stream <code>src</code>. * If this object is already connected to some * other piped output stream, an <code>IOException</code> * is thrown. * <p> * If <code>src</code> is an * unconnected piped output stream and <code>snk</code> * is an unconnected piped input stream, they * may be connected by either the call: * <p> * <pre><code>snk.connect(src)</code> </pre> * <p> * or the call: * <p> * <pre><code>src.connect(snk)</code> </pre> * <p> * The two * calls have the same effect. * * @param src The piped output stream to connect to. * @exception IOException if an I/O error occurs. */ public virtual void connect(PipedOutputStream src) { src.connect(this); }
internal PassiveInputStream(PipedOutputStream Out, int size) : base(Out, size) { m_Out = Out; }
internal PassiveInputStream(PipedOutputStream Out) : base(Out) { this.Out = Out; }
public virtual Stream getOutputStream() { PipedOutputStream stream = new PipedOutputStream(); m_io.setInputStream(new PassiveInputStream(stream , 32 * 1024 ), false); return stream; }
/// <exception cref="System.IO.IOException"></exception> public PassiveInputStream(Channel _enclosing, PipedOutputStream @out) : base(_enclosing ) { this._enclosing = _enclosing; this.@out = @out; }
/// <exception cref="System.IO.IOException"></exception> public MyPipedInputStream(Channel _enclosing, PipedOutputStream @out, int size) : base(@out) { this._enclosing = _enclosing; this.buffer = new byte[size]; }
/// <exception cref="System.IO.IOException"></exception> public MyPipedInputStream(Channel _enclosing, PipedOutputStream @out) : base(@out ) { this._enclosing = _enclosing; }
/** * Creates a <code>PipedInputStream</code> so * that it is connected to the piped output * stream <code>src</code>. Data bytes written * to <code>src</code> will then be available * as input from this stream. * * @param src the stream to connect to. * @exception IOException if an I/O error occurs. */ public PipedInputStream(PipedOutputStream src) { connect(src); }
public MyPipedInputStream(PipedOutputStream Out) : base(Out) { }
public string execClass(string className) { if (TEST_IN_SAME_PROCESS) { try { ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader()); Class mainClass = (Class)loader.loadClass(className); Method mainMethod = mainClass.getDeclaredMethod("main", typeof(string[])); PipedInputStream stdoutIn = new PipedInputStream(); PipedInputStream stderrIn = new PipedInputStream(); PipedOutputStream stdoutOut = new PipedOutputStream(stdoutIn); PipedOutputStream stderrOut = new PipedOutputStream(stderrIn); StreamVacuum stdoutVacuum = new StreamVacuum(stdoutIn); StreamVacuum stderrVacuum = new StreamVacuum(stderrIn); PrintStream originalOut = Console.Out; System.setOut(new PrintStream(stdoutOut)); try { PrintStream originalErr = System.err; try { System.setErr(new PrintStream(stderrOut)); stdoutVacuum.start(); stderrVacuum.start(); mainMethod.invoke(null, (Object) new string[] { new File(tmpdir, "input").getAbsolutePath() }); } finally { System.setErr(originalErr); } } finally { System.setOut(originalOut); } stdoutOut.close(); stderrOut.close(); stdoutVacuum.join(); stderrVacuum.join(); string output = stdoutVacuum.tostring(); if (stderrVacuum.tostring().length() > 0) { this.stderrDuringParse = stderrVacuum.tostring(); Console.Error.WriteLine("exec stderrVacuum: " + stderrVacuum); } return(output); } catch (MalformedURLException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (IOException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (IllegalArgumentException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (InvocationTargetException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (NoSuchMethodException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (SecurityException ex) { LOGGER.log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { LOGGER.log(Level.SEVERE, null, ex); } } try { string[] args = new string[] { "java", "-classpath", tmpdir + pathSep + CLASSPATH, className, new File(tmpdir, "input").getAbsolutePath() }; //string cmdLine = "java -classpath "+CLASSPATH+pathSep+tmpdir+" Test " + new File(tmpdir, "input").getAbsolutePath(); //Console.WriteLine("execParser: "+cmdLine); Process process = Runtime.getRuntime().exec(args, null, new File(tmpdir)); StreamVacuum stdoutVacuum = new StreamVacuum(process.getInputStream()); StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream()); stdoutVacuum.start(); stderrVacuum.start(); process.waitFor(); stdoutVacuum.join(); stderrVacuum.join(); string output = stdoutVacuum.tostring(); if (stderrVacuum.tostring().length() > 0) { this.stderrDuringParse = stderrVacuum.tostring(); Console.Error.WriteLine("exec stderrVacuum: " + stderrVacuum); } return(output); } catch (Exception e) { Console.Error.WriteLine("can't exec recognizer"); e.printStackTrace(System.err); } return(null); }
public PassiveInputStream(PipedOutputStream Out) : base(Out) { this.Out = Out; }
internal PassiveInputStream(PipedOutputStream Out) : base(Out) { m_Out = Out; }
internal MyPipedInputStream(PipedOutputStream Out, int size) : base(Out) { buffer = new byte[size]; }
public override void close() { if (m_Out != null) m_Out.close(); m_Out = null; }
public void connect(PipedOutputStream arg0) { Instance.CallMethod("connect", "(Ljava/io/PipedOutputStream;)V", arg0); }
public InternalLocalPushConnection(TransportLocal transport) : base(transport) { Repository dst; try { dst = new Repository(transport.remoteGitDir); } catch (IOException) { throw new TransportException(uri, "Not a Git directory"); } PipedInputStream in_r; PipedOutputStream in_w; PipedInputStream out_r; PipedOutputStream out_w; try { in_r = new PipedInputStream(); in_w = new PipedOutputStream(in_r); out_r = new PipedInputStream(); out_w = new PipedOutputStream(out_r); } catch (IOException ex) { dst.Close(); throw new TransportException(uri, "Cannot connect pipes", ex); } worker = new Thread(() => { try { ReceivePack rp = new ReceivePack(dst); rp.receive(out_r, in_w, null); } catch (IOException) { // Client side of the pipes should report the problem. } catch (Exception) { // Clients side will notice we went away, and report. } finally { try { out_r.close(); } catch (IOException) { // Ignore close failure, we probably crashed above. } try { in_w.close(); } catch (IOException) { // Ignore close failure, we probably crashed above. } dst.Close(); } }); worker.Name = "JGit-Receive-Pack"; worker.Start(); init(in_r, out_w); readAdvertisedRefs(); }
/// <summary> The main constructor for a ShellPanel. /// /// </summary> /// <param name="">engine /// The Jamocha engine that should be used with this GUI. /// /// </param> public ShellPanel(JamochaGui gui) : base(gui) { InitBlock(); // GUI construction // create the output area outputArea = new JTextArea(); outputArea.setEditable(false); outputArea.setLineWrap(true); outputArea.setWrapStyleWord(true); outputArea.addFocusListener(this); // set the font and the colors settingsChanged(); this.addFocusListener(this); // create a scroll pane to embedd the output area scrollPane = new JScrollPane(outputArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.VerticalScrollBar.addAdjustmentListener(this); // Assemble the GUI //UPGRADE_ISSUE: Constructor 'java.awt.BorderLayout.BorderLayout' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtBorderLayout"' setLayout(new BorderLayout()); //UPGRADE_ISSUE: Field 'java.awt.BorderLayout.CENTER' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtBorderLayout"' add(scrollPane, BorderLayout.CENTER); // create the button that clears the output area clearButton = new JButton("Clear Shell", IconLoader.getImageIcon("application_osx_terminal")); clearButton.addActionListener(this); JPanel clearButtonPanel = new JPanel(); //UPGRADE_ISSUE: Constructor 'java.awt.FlowLayout.FlowLayout' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtFlowLayout"' //UPGRADE_ISSUE: Field 'java.awt.FlowLayout.RIGHT' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtFlowLayout"' clearButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 1)); clearButtonPanel.add(clearButton); //UPGRADE_ISSUE: Field 'java.awt.BorderLayout' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000"' add(clearButtonPanel, BorderLayout.PAGE_END); // initialize the channel to the engine //UPGRADE_ISSUE: Constructor 'java.io.PipedOutputStream.PipedOutputStream' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaioPipedOutputStreamPipedOutputStream"' System.IO.StreamWriter outStream = new PipedOutputStream(); //UPGRADE_ISSUE: Constructor 'java.io.PipedInputStream.PipedInputStream' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaioPipedInputStreamPipedInputStream"' System.IO.StreamReader inStream = new PipedInputStream(); outWriter = new System.IO.StreamWriter(outStream); try { //UPGRADE_ISSUE: Method 'java.io.PipedInputStream.connect' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaioPipedInputStreamconnect_javaioPipedOutputStream"' inStream.connect(outStream); } catch (System.IO.IOException e) { SupportClass.WriteStackTrace(e, Console.Error); System.Environment.Exit(1); } channel = gui.Engine.MessageRouter.openChannel("JamochaGui", inStream); printPrompt(); moveCursorToEnd(); startTimer(); // initialize the channellistener for outputs from the engine initChannelListener(); // initialize the keylistener for key events initKeyListener(); // initialize the mouselistener for the context menu initPopupMenu(); }
public override void start() { try { PipedOutputStream pos = new PipedOutputStream(); m_io.setOutputStream(pos); PipedInputStream pis = new ChannelPipedInputStream(pos, 32 * 1024); m_io.setInputStream(pis); Request request = new RequestSftp(); request.request(m_session, this); m_buffer = new Buffer(m_rmpsize); m_packet = new Packet(m_buffer); int i = 0; int length; int type; byte[] str; // send SSH_FXP_INIT sendINIT(); // receive SSH_FXP_VERSION Header header = new Header(); header = fillHeader(m_buffer, header); length = header.Length; if (length > MAX_MSG_LENGTH) throw new SftpException(ChannelSftpResult.SSH_FX_FAILURE, "Received message is too long: " + length); type = header.HeaderType; // 2 -> SSH_FXP_VERSION m_server_version = header.RID; skip(length); // send SSH_FXP_REALPATH sendREALPATH(Util.getBytesUTF8(".")); // receive SSH_FXP_NAME header = fillHeader(m_buffer, header); length = header.Length; type = header.HeaderType; // 104 -> SSH_FXP_NAME m_buffer.rewind(); fill(m_buffer.m_buffer, 0, length); i = m_buffer.getInt(); // count str = m_buffer.getString(); // filename m_home = m_cwd = Util.getStringUTF8(str); str = m_buffer.getString(); // logname // SftpATTRS.getATTR(buf); // attrs m_lcwd = new File(".").CanonicalPath; } catch (Exception e) { if (e is JSchException) throw (JSchException)e; throw new JSchException(e.ToString()); } }
internal MyPipedInputStream(PipedOutputStream Out) : base(Out) { }
internal ChannelPipedInputStream(PipedOutputStream Out) : base(Out) { }
internal PassiveInputStream(PipedOutputStream Out, int size) : base(Out, size) { this.Out = Out; }
public PipedInputStream(PipedOutputStream arg0) : base(ProxyCtor.I) { Instance.CallConstructor("(Ljava/io/PipedOutputStream;)V", arg0); }
/// <exception cref="System.IO.IOException"></exception> public FullPipeInputStream(TimeoutOutputStreamTest _enclosing, PipedOutputStream src) : base(src) { this._enclosing = _enclosing; src.Write(new byte[PipedInputStream.PIPE_SIZE]); }
public runnable2(ChannelSftp channel, PipedOutputStream pos, String _src, SftpProgressMonitor monitor, int mode, Exception[] closed) { this.channel= channel; this.pos=pos; this._src=_src; this.monitor=monitor; this.mode=mode; this.closed=closed; }