简体   繁体   English

exec命令在php中不起作用,但是在终端/ putty中起作用

[英]exec command not working in php but works in terminal/putty

I am trying to run convert 'sample_(2).pdf[1]' 'sample.jpg' through php exec like below 我正在尝试通过php exec运行convert'sample_(2).pdf [1]''sample.jpg',如下所示

> exec(" convert 'sample_(2).pdf[1]' 'sample.jpg' ");

But it is not working in php but works great in terminal. 但是它在php中不起作用,但是在终端中效果很好。 I tried below codes also to check wethee exec is working with php. 我还尝试了以下代码,以检查wethee exec是否在使用php。

echo exec('whoami'); //It is working and giving me result //它正在工作并给我结果

exec("cp 'sample_(2).pdf' sample2.pdf"); exec(“ cp'sample_(2).pdf'sample2.pdf”);

//It is not working. //它不起作用。

But all the commands are running in terminal. 但是所有命令都在终端中运行。 Any idea would help me. 任何想法都会帮助我。 I am scratching my head for the last two days. 最近两天我都在挠头。

EDIT 编辑

I got it working. 我知道了 There were mistakes with my file path. 我的文件路径有误。

I guess that the web server does not have permission to write to the folder you want to write. 我猜想Web服务器没有写到要写的文件夹的权限。 Check the folder permissions for your webserver (probably "www-data"). 检查您的Web服务器的文件夹权限(可能是“ www-data”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM