使用 PHP 进行 telnet 连接
我需要编写一个 PHP 脚本来远程登录到路由器,运行命令并获取结果。 有谁知道 PHP 中的 telnet 连接库吗?
更新:这个请求(显而易见)是很久以前的请求了。 最后我不得不自己编写我需要的客户端库。 该库(以及更多模块)的代码是开源的,可在
I need to write a PHP script to telnet to a router, run a command and fetch the results. does anyone know a telnet connection library in PHP?
Update: This request (as is obvious) was for a long time ago. In the end I had to write the client library that I needed myself. The code for this library (and many more modules) is open source and available on github.
Thanks everyone for your answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Nicholas Hall 的 Github 上有一个可爱的类可用于 PHP telnet 连接:
https://github.com/ngharo/Random-PHP -Classes/blob/master/Telnet.class.php
There is a lovely class available for PHP telnet connectivity on Nicholas Hall's Github:
https://github.com/ngharo/Random-PHP-Classes/blob/master/Telnet.class.php
使用 stdin/stream_select & 阻塞流给你一个像客户端一样的 20 行 telnet
using stdin/stream_select & blocking streams gives you a 20 lines telnet like client
Pear::Net_Socket: http://pear.php.net/package/Net_Socket
为简单的 PHP telnet 机器人或会话扩展此类。
Pear::Net_Socket: http://pear.php.net/package/Net_Socket
Extend this class for a simple PHP telnet bot or session.
这对我有用。 第一部分将 ftp 文件上传到服务器,第二部分将登录到 telnet 服务器,并执行一个可以使用您刚刚通过 ftp 上传的文件的程序。 刚刚测试过。
that worked for me. the first part will upload the ftp file to the server, and the second part will lo onto the telnet server, and execute a program that can use the file you just uploaded by ftp. tested it just now.