简体   繁体   English

命令在 cmd 中工作但不是通过 php shell_exec

[英]command working in cmd but not through php shell_exec

I have a command in cmd which looks like below我在 cmd 中有一个命令,如下所示

C:\wamp\www\editor\DocTo-master\exe\docto -f C:\wamp\www\editor\uploaded\uploaded_files_21_original\AffidavitinDIR-4.docx -O "C:\wamp\www\editor\uploaded\uploaded_files_21_original\pdf\21.pdf" -T wdFormatPDF

When I run this in cmd, it works absolutely fine and gives output(doc to pdf) as expected.当我在 cmd 中运行它时,它工作得很好,并按预期提供输出(doc 到 pdf)。 However when I put the same command in php shell_exec like但是,当我在 php shell_exec 中放置相同的命令时

shell_exec('C:\wamp\www\editor\DocTo-master\exe\docto -f C:\wamp\www\editor\uploaded\uploaded_files_21_original\AffidavitinDIR-4.docx -O "C:\wamp\www\editor\uploaded\uploaded_files_21_original\pdf\21.pdf" -T wdFormatPDF');

I dont get the desired output with the above code in php.我没有在 php 中使用上述代码获得所需的输出。 Any help will be appreciated任何帮助将不胜感激

Seems like most of the problems have to do with permissions or redirection.似乎大多数问题都与权限或重定向有关。

Your current user credentials allow you to create files in that directory but does the webserver username?您当前的用户凭据允许您在该目录中创建文件,但网络服务器用户名是否可以?

Redirect stderr to stdout to get error information.将 stderr 重定向到 stdout 以获取错误信息。

Is the quoting right?引用正确吗?

Look in the webserver error logs.查看网络服务器错误日志。

I am the author of docto .我是docto的作者。

This is most probably a permissions issue in that php is not necessarily given the correct permissions to run word on your server.这很可能是权限问题,因为 php 不一定具有在您的服务器上运行 word 的正确权限。

I am running this myself on a Windows 2012 server running Word 2010, it works fine.我自己在运行 Word 2010 的 Windows 2012 服务器上运行它,它工作正常。 DocTo is installed on a subdirectory above the Webserver root. DocTo 安装在 Web 服务器根目录上方的子目录中。

PHP is running as NTSystem Authority PHP 以 NTSystem 权限运行

Also I am using exec rather than shell_exec not sure if that makes any differnce另外我正在使用 exec 而不是 shell_exec 不确定这是否有任何区别

For fix this problem you must create Desktop folder in these paths:要解决此问题,您必须在以下路径中创建桌面文件夹:

C:\\Windows\\SysWOW64\\config\\systemprofile\\Desktop C:\\Windows\\SysWOW64\\config\\systemprofile\\Desktop

C:\\Windows\\System32\\config\\systemprofile\\Desktop C:\\Windows\\System32\\config\\systemprofile\\Desktop

Then go to (Control Panel\\Administrative Tools\\Services) and right click on your apache service.然后转到(控制面板\\管理工具\\服务)并右键单击您的 apache 服务。 go to "Log On" tab and enable "Allow service to interact with desktop" option.转到“登录”选项卡并启用“允许服务与桌面交互”选项。

Then reset your apache service.然后重置您的 apache 服务。

http://pmlearning.info http://pmlearning.info

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

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