通过 PHP 向屏幕发送命令?

发布于 2024-12-06 03:48:01 字数 152 浏览 2 评论 0 原文

我想知道如何通过 PHP 在虚拟专用服务器上运行的屏幕上执行命令。

if(submit){
do "say This is a minecraft server." in screen.
}

提前致谢,

I was wondering how I could execute a command through PHP into a screen running on my virtual private server.

i.e.

if(submit){
do "say This is a minecraft server." in screen.
}

Thanks in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十年不长 2024-12-13 03:48:01

如果您在屏幕下运行脚本,则只需 echoprint 您想要显示的数据。

否则,您可以:

  • writewall
  • 写入您在屏幕(或其他系统)中tail -f的文件通过屏幕轮询新消息)
  • 在屏幕中运行您可以连接到的服务通过网络

If you are running the script under screen, then just echo or print the data you want to display.

Otherwise you can:

  • make a system call to write or wall
  • write to a file that you are tail -fing in the screen (or some other system by which the screen polls something for new messages)
  • run a service in the screen that you can connect to over the network
兔姬 2024-12-13 03:48:01

仍然不清楚你的意思,但如果这就是你正在寻找的,你可以使用反引号运算符执行linux命令,例如

echo `ls`; 

打印脚本所在目录的内容。因此,如果您想将命令打印到服务器,您可以这样做。

Still unclear on exactly what you mean, but if this is what you're looking for, you can execute linux commands by using the backtick operator, such as

echo `ls`; 

to print the contents of the directory where the script is located. So if you wanted to print commands to your server, you could do it that way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文