Renci.SshNet.ShellStream.Write C# (CSharp) Method

Write() public method

Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
The sum of and is greater than the buffer length. is null. or is negative. An I/O error occurs. The stream does not support writing. Methods were called after the stream was closed.
public Write ( byte buffer, int offset, int count ) : void
buffer byte An array of bytes. This method copies bytes from to the current stream.
offset int The zero-based byte offset in at which to begin copying bytes to the current stream.
count int The number of bytes to be written to the current stream.
return void
        public override void Write(byte[] buffer, int offset, int count)
        {
            foreach (var b in buffer.Take(offset, count))
            {
                if (_outgoing.Count < BufferSize)
                {
                    _outgoing.Enqueue(b);
                    continue;
                }

                Flush();
            }
        }

Same methods

ShellStream::Write ( string text ) : void

Usage Example

Exemplo n.º 1
0
        public void ExeSSH(Object s)
        {
            using (var conninfo = new PasswordConnectionInfo(ip, log, pass))
            {
                //  try

                Renci.SshNet.SshClient client = new Renci.SshNet.SshClient(conninfo);

                //  conninfo.Timeout = TimeSpan.FromSeconds(50);
                try
                {
                    client.Connect();
                }
                catch (Exception ex)
                {
                }
                try
                {
                    Renci.SshNet.ShellStream stream = client.CreateShellStream("ssh", 180, 324, 1800, 3600, 8000);
                    foreach (string command in list)
                    {
                        stream.Write(command + "\n");
                        System.Threading.Thread.Sleep(5000);
                        string temp_string = stream.Read();
                        //    File.WriteAllText(path, temp_string, Encoding.UTF8);
                        File.WriteAllText("C:/" + ip + ".txt", temp_string, Encoding.UTF8);
                        System.Threading.Thread.Sleep(5000);
                    }
                    client.Disconnect();
                }
                catch (Exception ex)
                {
                }
            }
        }
All Usage Examples Of Renci.SshNet.ShellStream::Write