【发布时间】:2014-11-16 02:36:20
【问题描述】:
我已经设置了一个网页,允许我远程执行我用来启动我的世界服务器的 bat 文件,以防我想在离开时玩。我已经成功地运行了 bat 文件并从我的站点远程启动了服务器,但是在服务器(我的桌面)上没有显示命令提示符,因为通常在正常运行 bat 文件时会出现这种情况。因此,我不知道停止服务器的好方法。
当使用 PHP 远程运行 bat 文件时,有什么方法可以让命令提示符显示在服务器上?有谁知道我可以通过网站在服务器上运行命令的任何简单方式,就像我使用命令提示符一样?
我的网站在与服务器相同的桌面上使用 wamp (apache) 运行,我将目录更改为 bat 文件的位置并能够执行它。
这是我的网站代码:
<?php
if (isset($_POST['button']))
{
echo getcwd() . "\n";
chdir('C:\wamp\www\MinecraftServer');
exec('server.bat', $output);
echo implode("\n", $output);
}
?>
<!doctype http>
<html>
<head>
<title> Index </title>
<style>
body {background-color: GREENYELLOW}
</style>
</head>
<body>
<h1> Welcome! </h1>
<h2> Are you here looking for the minecraft map? Click <a href="./WorldMap/map.html"> here </a>.</h2>
<form method="post">
<p>
<button name="button">Start Server</button>
</p>
</form>
</body>
</html>
蝙蝠文件:
"C:\Program Files\Java\jdk1.7.0_10\bin\java.exe" -Xmx4096M -Xms2048M -jar minecraft_server.1.8.exe nogui
pause
【问题讨论】:
标签: php apache batch-file minecraft