Hi guys,
I am trying to setup a telnet connection to a UNIX server. I need to pass three sudo commands to this server. I have found the following code but am unsure of how to modify it to suit my purposes. Any help would be much appreciated!
Thanks all :)
I am trying to setup a telnet connection to a UNIX server. I need to pass three sudo commands to this server. I have found the following code but am unsure of how to modify it to suit my purposes. Any help would be much appreciated!
Thanks all :)
Code:
Imports System.Net
Imports System.Net.Sockets
Imports System.IO
Imports System.Threading
Module modUNIX
Dim Stream As NetworkStream
Dim Server As String
Public Sub Main()
Dim Client As New TcpClient()
Try
Client.Connect(IPAddress.Parse(0.0.0.0), 23)
Stream = Client.GetStream()
Dim ReceiveThread As New Thread(AddressOf ReceiveData)
ReceiveThread.IsBackground = True
ReceiveThread.Start()
Dim w As New BinaryWriter(Stream)
Client.Close()
Catch Ex As Exception
MsgBox(Ex.ToString())
End Try
End Sub
Private Sub ReceiveData()
Dim r As New BinaryReader(Stream)
Do
If Stream.DataAvailable Then
Console.WriteLine(("RECEIVED: " + r.ReadString()))
End If
Loop
End Sub