Bor
Bor

Reputation: 793

php exec() syntax check

This works in the command prompt(in one line) :

cd C:\Program Files (x86)\LibreOffice 4\program && 
"C:\Program Files (x86)\LibreOffice 4\program\python.exe" unoconv -f pdf d:\class1.doc

but when it comes to do the same in PHP's exec() nothing happens - neither message nor any file, probably due to a syntax error :

echo exec('cd C:\\Program Files (x86)\\LibreOffice 4\\program &&
"C:\\Program Files (x86)\\LibreOffice 4\\program\\python.exe" unoconv -f pdf d:\\class1.doc');

Upvotes: 0

Views: 484

Answers (1)

Latheesan
Latheesan

Reputation: 24116

Once you have cd into a dir, no need to call the executable within it from the full path again. you can call it directly.

Try this:

<?php

// Test
$ret = exec('cd "C:\Program Files (x86)\LibreOffice 4\program\" && python.exe unoconv -f pdf d:\\class1.doc', $output, $error);

// Debug
var_dump($ret);
var_dump($output);
var_dump($error);

?>

Take a look at the documentation here: https://www.php.net/function.exec

Upvotes: 1

Related Questions