可以使用PHP连接到远程桌面吗? [英] Possible to connect to Remote Desktop with PHP?

查看:434
本文介绍了可以使用PHP连接到远程桌面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想经常连接一些服务器来运行程序.但是,为了简化操作,我想使一个PHP脚本通过远程桌面连接到每个脚本,并运行每个脚本.这可能吗?如果是这样,我应该从哪里开始?一个例子会很可爱.

I've got a few servers that I'd like to connect to every so often to run a program. However, to make it easier, I'd like to make a PHP script connect to each of them via remote desktop and run each of them. Is this possible? If so, where should I start? An example would be lovely.

推荐答案

从理论上讲,您可以实现一个PHP脚本,该脚本可以与RDP协议中的服务器进行通信,但是我当然不想尝试构建一个脚本来可以做任何有意义的事情,因为RDP的构建是为了向连接的客户端公开远程计算机的用户界面,而PHP的构建首先是为了处理文本.

In theory you could implement a PHP script that could communicate with a server in the RDP protocol, but I certainly wouldn't want to try to build a script that can do anything meaningful, as RDP is built to expose a remote machine's user interface to the connected client and PHP is built first and foremost to manipulate text.

如果您希望PHP脚本远程控制另一台计算机,那么SSH是更明智的选择,因为PHP可以轻松连接到远程cmputer的CLI并通过shell命令向服务器发出命令,这些命令是文本命令,因此很容易用PHP生成.

If you want a PHP script to remotely control another computer, then SSH is a far more sensible option, as PHP could easily connect to the remote cmputer's CLI and issue commands to the server via shell commands, which are textual and therefore easily generated with PHP.

另一方面,使用RDP与远程计算机进行连接将非常困难.只需考虑单击一个图标即可获取目录列表作为开始.首先,您必须确定鼠标指针在哪里,要单击的图标是否可见以及是否在其边界框相对于鼠标指针的位置.然后,您必须发出命令以将鼠标指针移至边界框内,然后检查鼠标指针是否位于正确的位置(本地或其他远程用户可能正在移动鼠标),然后发出一对鼠标指针.点击之间的延迟很短.

On the other hand, interfacing with the remote computer with RDP would be extremely difficult. Just think about clicking on an icon to get a directory listing for a start. You'd first have to determine where the mouse pointer is, whether the icon you want to click is visible and if so where its bounding box is relative to the mouse pointer. You'd then have to issue commands to move the mouse pointer to within the bounding box, then check that the mouse pointer is in the right place (a local or other remote user might be moving the mouse around) and then issue a pair of clicks with a short delay between them.

例如,这将比发出"cd C:\ Program Files \"后跟"dir"要困难得多.

That's going to be a lot harder than issuing "cd C:\Program Files\" followed by "dir", for example.

这篇关于可以使用PHP连接到远程桌面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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