与Telnet通讯 [英] communicate with Telnet

查看:118
本文介绍了与Telnet通讯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们想通过CSharp pg与控制台远程通信.我们编写了命令Process p = Process.Start (@ IP, port number).问题是我们想通过程序发送的流在控制台上执行命令.我们尝试使用RedirectStandardOutput和输入,但是没有用.
我也有一个问题,因为我想发送密码以自动与路由器进行讨论,因为当我连接到路由器时,他会问我密码...(我知道路由器的密码)

如果您有解决方案,将不胜感激.

谢谢您.

Hi,

We want to communicate with a console telent through our CSharp pg. We wrote the command Process p = Process.Start (@ IP, port number) The problem is we want to execute commands on the console through streams sent from the program. We tried to work with RedirectStandardOutput and input but it did not work.
I also have a problem because I want to send the password to automatically enter into discussion with the router because he ask me the password when I connect to it...(i know the password of my router)

If you have a solution you would be grateful.

Thank you

推荐答案

我很想帮助尝试使用System.Diagnostic.Process.Start的人们.他们认为他们可以节省别人的时间,但实际上他们深深陷入了过程通讯问题中.这是可能的,但是……请记住,这不是您的过程,它的行为不会像您想要的那样.记住,流程之间是很好的隔离.您正在招来各种各样的麻烦.因此,扎根在99.95%的情况下是一个大错误.

我可以帮助您运行此过程并正确设置重定向.这不是很难.只是没有意义.如果您更全面地阅读System.Diagnostic.Process.Start System.Diagnostics.ProcessStartInfo上的MSDN帮助页面,则可以或多或少地轻松地学习全部内容.

以Telnet为例.您需要绝对不同的方法.实现基于System.Net的Telnet要容易得多:您将能够调试过程,清楚地看到所有问题并进行修复等.

首先,请阅读此CodeProject文章:快速工具:简约的Telnet库 [
I am tired to help people trying to use System.Diagnostic.Process.Start. They think they save time using some work of someone else, but in fact get sunk deeply in the problem of process communications. This is possible, but… remember, this is not your process, it won''t behave like you want. Remember, processes are well isolated. You''re inviting all kinds of trouble. So, taking this root is a big mistake in 99.95% of cases.

I could help you to run this process and set up re-directions properly; this is not too hard to. It just does not make sense. You can more or less easily learn it all if you read MSDN help pages on System.Diagnostic.Process.Start and System.Diagnostics.ProcessStartInfo more thoroughly.

Take the example of Telnet. You need absolutely different approach. It''s much easier to implement Telnet based on System.Net: you will be able to debug your process, clearly see all problems and fix them, etc.

To start, read this CodeProject article: Quick tool : A minimalistic Telnet library[^].

—SA


这篇关于与Telnet通讯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆