Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: CreateShell

$
0
0
Oleg,

I used your example to also create a solution:
 Function SendCommand(cmd As String, s As ShellStream) As String
        Try
            reader = New StreamReader(s)
            writer = New StreamWriter(s)
            writer.AutoFlush = True
            writer.WriteLine(cmd)
            While s.Length = 0
                Thread.Sleep(500)
            End While
        Catch ex As Exception
            Debug.WriteLine("SendCommand(" & cmd & ") caught exception: " & ex.ToString())
        End Try
        Return reader.ReadToEnd()
    End Function
    Function SendCommandW(cmd As String, s As ShellStream) As String
        Try
            reader = New StreamReader(s)
            writer = New StreamWriter(s)
            writer.AutoFlush = True
            writer.Write(cmd)
            While s.Length = 0
                Thread.Sleep(500)
            End While
        Catch ex As Exception
            Debug.WriteLine("SendCommandW(" & cmd & ") caught exception: " & ex.ToString())
        End Try
        Return reader.ReadToEnd()
    End Function
    Function SendCommandCR(cmd As String, s As ShellStream) As String
        Try
            reader = New StreamReader(s)
            writer = New StreamWriter(s)
            writer.AutoFlush = True
            writer.Write(cmd & vbCr)
            While s.Length = 0
                Thread.Sleep(500)
            End While
        Catch ex As Exception
            Debug.WriteLine("SendCommandCR(" & cmd & ") caught exception: " & ex.ToString())
        End Try
        Return reader.ReadToEnd()
    End Function
    Function SendCommandLF(cmd As String, s As ShellStream) As String
        Try
            reader = New StreamReader(s)
            writer = New StreamWriter(s)
            writer.AutoFlush = True
            writer.Write(cmd & vbLf)
            While s.Length = 0
                Thread.Sleep(500)
            End While
        Catch ex As Exception
            Debug.WriteLine("SendCommandLF(" & cmd & ") caught exception: " & ex.ToString())
        End Try
        Return reader.ReadToEnd()
    End Function
A little respect for the VB.NET folks!

VS 2012 Ultimate

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>