通过PHP在屏幕上运行和接收命令 [英] Run and Receive a Command in screen via PHP

查看:62
本文介绍了通过PHP在屏幕上运行和接收命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作Minecraft控制面板,但是对于如何向每个屏幕发送命令感到困惑.我了解如何在屏幕上执行命令,但不了解如何读取输出.

I'm making a Minecraft control panel, but are sort of confused on how to send a command to each screen. I understand how to execute a command to a screen, but I don't understand to read the output.

例如我有屏幕A和屏幕B.我想在屏幕A中执行某些操作,获取输出,然后退出屏幕.

Ex. I have screen A and screen B. I want to execute something in screen A, and get the output, and then exit the screen.

推荐答案

这是一个更简单的解决方案: 使用Websend bukkit插件在两个服务器中.当安装插件和设置php类时,PHP可以简单地执行命令并接收输出,这也可以比bash屏幕更复杂,并且更易于设置和使用.

Here's an easier solution: Use Websend bukkit plugin (Download&info) in both servers. PHP can simply execute commands and receive outputs when plugin is installed and php classes setted up, also this can be more complex than bash screen, and much easier to setup and use.

这里是一个使用示例:

<?php
include_once 'Websend.php';

//Replace with bukkit server IP. To use a different port, change the constructor to new Websend(ip, port)
$ws = new Websend($ServerIP, $ServerPort); 

//Replace with password specified in Websend config file
$ws->connect("password");

$ws->doCommandAsConsole("give ".$PlayerName." 64 1");
$ws->disconnect();
?>

在此示例中,脚本项指向变量定义的播放器. 您可以通过替换$ws->doCommandAsConsole("give ".$PlayerName." 64 1");' to $ ws-> doCommandAsConsole("$ _ REQUEST ['customCMD']")来执行定制变量命令.其中的customCMD是GET或POST表单中的字段.

In this example the script item to a variable-definied player. You can execute a custom variable command with replacing $ws->doCommandAsConsole("give ".$PlayerName." 64 1");' to$ws->doCommandAsConsole("$_REQUEST['customCMD']"); where customCMD is a field in a GET or POST form.`

这篇关于通过PHP在屏幕上运行和接收命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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