I am trying to create an app that will interact with Telnet.
Right now I am using the console app project in VS Studio 2008.
It doesnt seem to work. I want to telnet to a server and send commands.
I don't get any errors in VS, but when I run the project nothing seems to happen. I have a console box pop up but it is just a flsahing cursor.
I would like to accomplish a few things.
1.send commands back and forth via telnet
2.log my telnet session, I thought I could do that with the -f argument that works outside of my project when I use telnet
3.View what is actually happening in telnet. The only way I know to do
this is to set StartInfo.UseShellExecute = True, but if I do that I can see the telnet prompt in that case, but I cannot send standard input etc.
Here is my Code
Right now I am using the console app project in VS Studio 2008.
It doesnt seem to work. I want to telnet to a server and send commands.
I don't get any errors in VS, but when I run the project nothing seems to happen. I have a console box pop up but it is just a flsahing cursor.
I would like to accomplish a few things.
1.send commands back and forth via telnet
2.log my telnet session, I thought I could do that with the -f argument that works outside of my project when I use telnet
3.View what is actually happening in telnet. The only way I know to do
this is to set StartInfo.UseShellExecute = True, but if I do that I can see the telnet prompt in that case, but I cannot send standard input etc.
Here is my Code
Code:
Module Module1
Public Sub Main()
Dim telnetTest As New Process
Dim StartInfo As New System.Diagnostics.ProcessStartInfo
' Run Telnet
StartInfo.FileName = "telnet.exe"
StartInfo.Arguments = "54.204.44.77 -f h:\TestNewGT.txt"
StartInfo.RedirectStandardInput = True
StartInfo.RedirectStandardOutput = True
StartInfo.UseShellExecute = False
StartInfo.CreateNoWindow = True
telnetTest.StartInfo = StartInfo
telnetTest.Start()
Dim SR As System.IO.StreamReader = telnetTest.StandardOutput
Dim SW As System.IO.StreamWriter = telnetTest.StandardInput
'Enter Telnet Commands
SW.WriteLine("My First Command")
SW.WriteLine("My Second Command")
SW.WriteLine("my third command")
Console.ReadLine()
'Displayes the results...
SR.ReadToEnd()
SW.Close()
SR.Close()
End Sub
End Module