I have ubuntu 12.04 with PHP 5.3,Apache2 installed. I needed to count the words in a doc file using php and pdf. while i am able to do shell_exec for text to pdf but not for wc. here is the code
<?php
$content = shell_exec('pdftotext test.pdf -');
echo str_word_count($content);// this is working
$word_count = exec('wc -w test.doc'); //this is not working
echo $word_count;
?>
However the code works in command line.
Actually there was a problem with my ubuntu Release 12.04. I tried it with ubuntu 11.10 and with LAMP. And everything worked like a charm. I will reinstall this dist of ubuntu and check again.
<?php
echo exec('wc -w test.doc;echo $?');
?>
try this to see what you can get. if the result is 0,it works,otherwise some error informations will be given.
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.