unix output to VB.net

March 30, 2009 at 02:29:47
Specs: Windows XP
Hello Guys, I am beginer in vb and I am developing a project that I have to telnet to a device running in linux only and then after the connection is done I have to send a command then it will provide an output. This output I want to display in vb 2008 textbox. I am ving problems but so far I am able to telnet , connect and send command but I don't know what way to get the result to vb.net textbox......can someone please help out. Thanks and this is my code .....

Try
Dim prcProcess As New Process()
'Dim srdOutput As IO.StreamReader
prcProcess.StartInfo.FileName = "cmd"
prcProcess.StartInfo.UseShellExecute = False
prcProcess.StartInfo.CreateNoWindow = False
prcProcess.EnableRaisingEvents = True

prcProcess.StartInfo.RedirectStandardOutput = True
' prcProcess.StartInfo.RedirectStandardInput = True
'prcProcess.StartInfo.RedirectStandardError = True
prcProcess.Start()
'Dim swrInput As IO.StreamWriter = prcProcess.StandardInput
'swrInput.AutoFlush = True
System.Windows.Forms.SendKeys.Send("telnet 192.168.22.1")
System.Windows.Forms.SendKeys.Send("{ENTER}")
System.Windows.Forms.SendKeys.Send("/usr/local/bin/hcc-example1-client")
System.Windows.Forms.SendKeys.Send("{ENTER}")


prcProcess.BeginOutputReadLine()
prcProcess.WaitForExit()
If Not prcProcess.HasExited Then
MsgBox("OK")
prcProcess.Kill()
End If
'swrInput.Flush()
'srdOutput = New IO.StreamReader("C:\Temp\AdPlusOutput.txt")
'txtoutput.Text = srdOutput.ReadToEnd
'srdOutput.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)

'Proc.EnableRaisingEvents = True
'Proc.Start()

End Try


See More: unix output to VB.net

Report •


#1
March 30, 2009 at 11:25:17
Telnet.exe doesn't use standard streams, so it's a little hard to get anything out of it. While you could probably reach into the program and find its screen buffer, it seems a little clunky, and SendKeys is evil. I suggest you give this guy's blog post a look.

Report •

#2
March 31, 2009 at 23:11:50
so then what is the solution for this I only want to display the result that the target display in the unix cmd......coz when ever i connect to the target I am out of windows and I am in the target which is running linux only.

Report •

#3
April 2, 2009 at 14:27:31
Well, according to the blog I linked, he suggests using System.Net.Sockets to emulate a telnet client. As for the cross platform issue, it shouldn't be a problem. The only real difference between the two is the end of line marker. Windows uses characters (0x10, 0x13), whereas Unix uses just 0x13.

Report •

Related Solutions

#4
April 2, 2009 at 16:29:17
OK BRO CAN I HAVE AN EXAMPLE CODE OF THAT TYPE .....THANK YOU

Report •


Ask Question