php - exec 无法正确执行 php 命令 centos 7

标签 php linux csv nginx

使用

xls2csv -x/usr/share/nginx/html/price_list_EN.xls -s cp1252 -d 8859-1 >/usr/share/nginx/html/price_list_EN.csv

在 Linux 命令行中它可以正常工作并正确导出,但如果我在 php 上使用它

$transf2 = "xls2csv -x /usr/share/nginx/html/price_list_EN.xls -s cp1252 -d 8859-1 > /usr/share/nginx/html/price_list_EN.csv";

exec($transf2);

出现一个名为price_list_EN.csv的文件,但它仍然是空的...

最佳答案

尝试从 shell 执行这样的命令

su -s /bin/bash -c "xls2csv -x /usr/share/nginx/html/price_list_EN.xls -s cp1252 -d 8859-1 > /usr/share/nginx/html/price_list_EN.csv" www-data(your webserver user name)

然后你调试错误

关于php - exec 无法正确执行 php 命令 centos 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47341770/

相关文章:

linux - 如何从特定文件夹中获取 PID

python - 如何使用 CSV 作为 Tensorflow 神经网络的输入数据?

php - Laravel 5.4 路由

php - 执行更多或更复杂的 SQL 查询,或使用 PHP 过滤数据?

linux - 来自 Artifactory 的 docker pull 导致 "net/http: request canceled"不一致

linux - 交叉编译 glibc 导致构建错误

r - 从给定文件夹读取多个 csv 文件时如何获取命名列表?

python - 将大型 CSV 从 Cloud Storage 导入 App Engine Datastore

php - Wamp Server 3.0.8图标托盘右键菜单不一样

php - Vagrant 家园缓慢