My problem is that I have an Excel XLSX file with non-ascii sheet name (
Общий отчет) and I’m trying to convert it to CSV using in2csv tool. I run it from PHP using
On my local machine (Windows 10 x64) it’s workong OK. I’m trying to run it on the CsntOS x64 VDS, and when I start my PHP script (which uses
exec to call in2csv tool) from terminal – it works OK too. But when I run it from cron (
php -f ./task.php) – it produces no error but the resulting CSV file is blank!
I did some tests, checking user and group running PHP script, python default encoding, but still have no clue. Please help!
Here is the command to convert the file:
in2csv --locale ru_RU --sheet "Общий отчет" --encoding windows-1251 "prices.xlsx" > "prices.csv"
Finally I figured it out.
The command in PHP’s
exec function should look like this:
exec('/usr/bin/in2csv --locale ru_RU --sheet "Общий отчет" --encoding windows-1251 "/home/admin/www/html/prices.xlsx" > "/home/admin/www/html/prices.csv"');
And the cron command should look like this:
/usr/bin/php -f /home/admin/www/html/task.php
That is, you need to provide full paths to all executables, and this will work both in terminal and in Cron!