如何使用Php执行docx2txt shell脚本?
我正在使用提取如何使用Php执行docx2txt shell脚本?,php,shell,terminal,docx,Php,Shell,Terminal,Docx,我正在使用提取.docx内容。 我可以通过在terminal中运行shell脚本来实现这一点 下面是终端shell脚本 niveus@niveus:/var/www/docx2txt$ ./docx2txt.sh test.docx Text extracted from <test.docx> is available in <test.txt>. niveus@niveus:/var/www/docx2txt$。/docx2txt.sh test.docx 从
.docx
内容。
我可以通过在terminal中运行shell脚本来实现这一点
下面是终端
shell脚本
niveus@niveus:/var/www/docx2txt$ ./docx2txt.sh test.docx
Text extracted from <test.docx> is available in <test.txt>.
niveus@niveus:/var/www/docx2txt$。/docx2txt.sh test.docx
从中提取的文本在中提供。
但是我也想用php运行这个脚本
我试过这个
<?php
$docxFilePath = "test.docx";
echo $content = shell_exec('./docx2txt.sh '.escapeshellarg($docxFilePath));
?>
并且它输出无法从中提取文本代码>
(docx2txt.sh
和test.txt都在同一个文件夹中docx2txt
)问题在于权限。将docx2txt文件夹的权限更改为chmod 777
下面的php
代码有效
<?php
$docxFilePath = "test.docx";
echo $content = shell_exec('./docx2txt.sh '.escapeshellarg($docxFilePath));
?>
使用下面的命令更改文件夹权限
sudo chmod 777 -R /var/www/docx2txt
你能检查一下这个解决方案吗:它在命令末尾有hypen
-
@Makesh即使在添加hypen-