如果我希望所有命令都是 运行 在同一个 shell 实例上而不是每次都在不同的实例上,我应该如何调用 shell_exec 或 php 中的 exec?
How should I invoke shell_exec or exec in php if I want all the commands to be run on same shell instance and not on different instances everytime?
我在一个主题上搜索了将近一个星期,但仍然无法在 Internet 上找到合适的答案。我想做的是通过我的服务器发出多个 shell_exec 或 exec 命令,它是 运行ning native PHP,我将为此使用 shell_exec 或 exec 函数。但我的问题是,每次我调用该函数时,它都会创建一个新的 shell 实例和 运行s。但是我希望我的所有命令在同一个 shell 实例中都是 运行。有什么帮助吗?
打开一个新的屏幕会话。将其命名为 test
:
screen -S test
使用 Ctrl+A 后跟 d[= 从屏幕会话中分离33=].
将命令发送到该屏幕会话:
screen -S test -X stuff 'echo enter command here'`echo -ne '5'`
- 将上述命令包装在 exec 中并设置适当的权限(即 PHP 应该能够访问
test
屏幕会话)。
我在一个主题上搜索了将近一个星期,但仍然无法在 Internet 上找到合适的答案。我想做的是通过我的服务器发出多个 shell_exec 或 exec 命令,它是 运行ning native PHP,我将为此使用 shell_exec 或 exec 函数。但我的问题是,每次我调用该函数时,它都会创建一个新的 shell 实例和 运行s。但是我希望我的所有命令在同一个 shell 实例中都是 运行。有什么帮助吗?
打开一个新的屏幕会话。将其命名为
test
:screen -S test
使用 Ctrl+A 后跟 d[= 从屏幕会话中分离33=].
将命令发送到该屏幕会话:
screen -S test -X stuff 'echo enter command here'`echo -ne '5'`
- 将上述命令包装在 exec 中并设置适当的权限(即 PHP 应该能够访问
test
屏幕会话)。