0

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');

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

6 Comments

the usage of python.exe is fine but still var_dumps empty strings
var dump of all 3 is empty?
$ret : string(0) "" $output : array(0) { } $error : int(1) - cannot see the error ?
for the purpose of testing, can you copy the class1.doc into C:\Program Files (x86)\LibreOffice 4\program` and try this line and see if it works: $ret = exec('cd "C:\Program Files (x86)\LibreOffice 4\program\" && python.exe unoconv -f pdf class1.doc', $output, $error);`
It should be in another partition the converted document, in C:\ it asks for permissions, even if i have
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.