2

I'm using docx2txt to extract .docx contents. I can achieve this by running the shell script in terminal.

below is the Terminal shell script,

 niveus@niveus:/var/www/docx2txt$ ./docx2txt.sh test.docx

 Text extracted from <test.docx> is available in <test.txt>.

But I want to run this script with php as well.

I tried this,

<?php

 $docxFilePath = "test.docx";
 echo  $content = shell_exec('./docx2txt.sh '.escapeshellarg($docxFilePath));

?>

and it outputs Failed to extract text from !

(both docx2txt.sh and test.txt are in the same folder docx2txt)

Madhu
  • 2,643
  • 6
  • 19
  • 34
  • CAn you check this solution : It has hypen `-` at the end of command. http://stackoverflow.com/a/14348458/1218075 – Makesh Jul 02 '15 at 11:14
  • @Makesh i am not getting the desired result even after adding hypen `-` – Madhu Jul 02 '15 at 11:16

2 Answers2

1

The issue was the permission. After changing the permission of the docx2txt folder to chmod 777 the following php code worked.

<?php

 $docxFilePath = "test.docx";
 echo  $content = shell_exec('./docx2txt.sh '.escapeshellarg($docxFilePath));

?>
Madhu
  • 2,643
  • 6
  • 19
  • 34
1

Change your folder permission using below command

sudo chmod 777 -R /var/www/docx2txt
Jayanth Suvarna
  • 187
  • 2
  • 9