简体   繁体   中英

command working in cmd but not through php shell_exec

I have a command in cmd which looks like below

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. However when I put the same command in php shell_exec like

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. 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.

Is the quoting right?

Look in the webserver error logs.

I am the author of docto .

This is most probably a permissions issue in that php is not necessarily given the correct permissions to run word on your server.

I am running this myself on a Windows 2012 server running Word 2010, it works fine. DocTo is installed on a subdirectory above the Webserver root.

PHP is running as NTSystem Authority

Also I am using exec rather than shell_exec not sure if that makes any differnce

For fix this problem you must create Desktop folder in these paths:

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

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

Then go to (Control Panel\\Administrative Tools\\Services) and right click on your apache service. go to "Log On" tab and enable "Allow service to interact with desktop" option.

Then reset your apache service.

http://pmlearning.info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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