Пример #1
0
        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);
        }
Пример #2
0
 public virtual void connect(PipedInputStream snk)
 {
     if (snk == null)
     {
         throw new NullReferenceException();
     }
     else if (sink != null || snk.connected)
     {
         throw new IOException("Already connected");
     }
     sink          = snk;
     snk.m_in      = -1;
     snk.m_out     = 0;
     snk.connected = true;
     int t = 0;
 }
Пример #3
0
 internal PassiveOutputStream(PipedInputStream In)
     : base(In)
 {
 }
Пример #4
0
 /**
 * Creates a piped output stream connected to the specified piped
 * input stream. Data bytes written to this stream will then be
 * available as input from <code>snk</code>.
 *
 * @param      snk   The piped input stream to connect to.
 * @exception  IOException  if an I/O error occurs.
 */
 public PipedOutputStream(PipedInputStream snk)
 {
     connect(snk);
 }
Пример #5
0
 public virtual void connect(PipedInputStream snk)
 {
     if (snk == null)
     {
         throw new NullReferenceException();
     }
     else if (sink != null || snk.connected)
     {
         throw new IOException("Already connected");
     }
     sink = snk;
     snk.m_in = -1;
     snk.m_out = 0;
     snk.connected = true;
     int t=0;
 }
Пример #6
0
 /**
  * Creates a piped output stream connected to the specified piped
  * input stream. Data bytes written to this stream will then be
  * available as input from <code>snk</code>.
  *
  * @param      snk   The piped input stream to connect to.
  * @exception  IOException  if an I/O error occurs.
  */
 public PipedOutputStream(PipedInputStream snk)
 {
     connect(snk);
 }