I am a bit desperate about this problem that I have been trying to solve for several days now.
I'm trying to run a Python script from the exec() function in php. The script is called but the print job is never executed.
This process has been running for several years and for no clear reason it suddenly stopped working.
On my home computer, it works without any problem. In my virtual machine, nothing happens. The print() functions present in the script are well displayed by the return value received by php but the printing is not executed.
The virtual machine is a test environment, in production it is also an physical machine.
PHP
<?php
exec("py C:\xampp\htdocs\test\test.py", $out, $res);
echo "<pre>";
print_r($out);
echo "</pre>";
echo "<pre>";
print_r($res);
echo "</pre>";
?>
PYTHON
if __name__ == "__main__":
try:
filename = "C:/xampp/htdocs/test/test.pdf"
win32api.ShellExecute(0, "print", filename, None, ".", 0)
except Exception as e:
print(f "An error occured during print_pdf : {e}")
The two environments are approximately the same:
* Build 1909
* Python 3.9.5
* Apache 2 & php > 7
* local user member of the administrators group
* local user owner of the apache2 service
* Same printer configured by default
I'd like to point out that running the script directly from the CLI works on both machines.
On the problematic machine, exec() only returns the result of print(..)
I already opened a thread a few months ago about this problem but received no response.
Thank you in advance.