我怎么... php exec()命令不能与其他应用程序一起使用 [英] How do i...php exec() command doesn't work with other application

查看:71
本文介绍了我怎么... php exec()命令不能与其他应用程序一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用php开发的应用程序,我想通过我的打印机打印抖动图像所以我正在做的是我有一个名为ImageMagick的应用程序。在使用命令提示符的此应用程序中,我将传递图像路径和目标文件夹。因此,当我在命令提示符下运行命令时,它将转换图像并将其保存在目标文件夹中。



我尝试过:



I have an application which was developed using php and I want to print a dithering image through my printer so what I am doing is I have an application called ImageMagick. In this application using command prompt I will pass an image path and the destination folder. So when I run the command in the command prompt it will convert the image and save it in destination folder.

What I have tried:

Firstly I tried the php exec() for the below code
<pre><pre lang="PHP"><pre><?php
     echo exec('ipconfig');
    ?>



以上代码在浏览器上显示输出



当我给出以下代码:


The above code gives the output on the browser

When I give the below code:

<pre lang="PHP"><pre><?php
     echo exec('date');
   ?>



它给出如下输出


It gives the output as below

Enter the new date: (mm-dd-yy)



但是当我在命令提示符下运行date命令时它会给出当前命令date

我试图在php代码中运行Imagemagick命令,如下所示


But When I run the date command on the command prompt it gives the current date
I tried to run the Imagemagick command in php code as shown below

<pre lang="PHP"><pre><?php
echo exec('convert "C:\bhargav\dev\download.jpg" -resize 384 -dither FloydSteinberg -remap pattern:gray50 "C:\bhargav\dev\con.jpg"');
?>



但它不会将任何图像保存为输出,并且浏览器上不会显示错误。


But it doesn't save any image as output and no error is shown on the browser.

convert "C:\bhargav\dev\download.jpg" -resize 384 -dither FloydSteinberg -remap pattern:gray50 "C:\bhargav\dev\con.jpg"



当在命令提示符中给出上面的命令它给我输出。



我哪里错了?


when the above command is given in the command prompt it gives me the output.

Where am I going wrong?

推荐答案

任何错误都可能是 stderr ,而不是 stdout 。我怀疑php exec()只捕获 stdout 内容(默认情况下,否则)。您需要查看服务器错误日志,而不是浏览器,以查看来自exec()程序的错误消息。
Any errors would likely be going to stderr, not stdout. I suspect php exec() only captures stdout content (by default, if otherwise). You need to look at the server error log, not the browser, to see error messages from exec()'d programs.


这篇关于我怎么... php exec()命令不能与其他应用程序一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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