php我如何启动运行的外部程序-系统和exec出现问题 [英] php How do I start an external program running - Having trouble with system and exec

查看:330
本文介绍了php我如何启动运行的外部程序-系统和exec出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在受控的xp,仅限Intranet的环境中运行,并且需要从PHP应用程序启动外部进程. (备份,报告等)

I'm running in a controlled, xp, intranet only environment and I need to start external processes from a PHP applications. (Backups, Reports etc.)

我可以让系统或执行程序启动以静默方式运行的进程.这是一个简单的示例

I can get system or exec to start processes that work silently. Here's a simple example

<?php exec ("echo hello > hello.txt");?> 

我可以让它执行没有可见输出的bat文件.

I can get it to execute a bat file that has no visible output.

我找不到任何可以运行屏幕的程序,例如报告生成器或记事本...

I can't get any program that has a screen to run such as a report generator or notepad...

<?php exec ("explorer");?>

什么也没做.或与系统相同

doesn't do anything. or same for system

推荐答案

您期望什么行为?调用system('notepad')可以正常工作-只是不显示GUI.它在后台运行,PHP耐心地坐在那里等待记事本自身关闭(并且只有在您从进程列表中杀死记事本时才会继续).

What behavior are you expecting? Calling system('notepad') works fine - it just doesn't display the GUI. It runs in the background, and PHP sits there patiently waiting for notepad to close itself (and only continues if you kill notepad from the process list).

如果您希望它弹出GUI,我可以肯定您不能这样做. ;)一种选择是写出一个批处理脚本(file_put_contents('runme.bat', 'notepad hello.txt'))并使该批处理脚本排队(使用Windows调度程序或Windows上与cron等效的任何程序)以异步方式运行(并在最后清除自身) ).

If you're expecting it to pop up a GUI, I'm fairly certain that you can't do that. ;) An option might be to write out a batch script (file_put_contents('runme.bat', 'notepad hello.txt')) and have that batch script queued (with Windows scheduler or whatever the cron-equivalent is on Windows) to run in an async fashion (and clear itself at the end).

这篇关于php我如何启动运行的外部程序-系统和exec出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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