ik heb volgende probleem:
Python script dat aangeroepen wordt via een PHP bestand (beide zijn eenvoudige test bestandjes)
python script:
#import serial
import json
D = "dit is een string"
print ("op scherm")
print()
print (json.dumps(D))
...
PHP bestand
<?php
$command = escapeshellcmd("python /var/www/html/test/var.py");
$output = shell_exec($command);
echo $output."<br>";
echo "php_works";
?>
Als ik het Python bestand op de server uitvoer werkt het zoals voorzien
------------------------------------------------------
xxx@pi:/var/www/html/test $ python var.py
op scherm
"dit is een string"
--------------------------------------------------------
In de browser komt echter op het scherm het volgende:
----------------------------------
op scherm "dit is een string"
php_works
-------------------------------
Waarom wordt die "new line" niet geprint?
Het grootste probleem zit hem echter bij de module serial.
Als ik de commentaar voor de "import serial" in het python bestand weg haal komt er niets meer in de browser.
---------------
php_works
-----------------
Wat kan hier het probleem zijn?
Python versie: 3.9.2
heb op de server ook al volgende gedaan
pip3 uninstall serial
pip3 uninstall pyserial
pip3 install pyserial
Wie kan helpen?
Dank u
Herman
...
Python script dat aangeroepen wordt via een PHP bestand (beide zijn eenvoudige test bestandjes)
python script:
#import serial
import json
D = "dit is een string"
print ("op scherm")
print()
print (json.dumps(D))
...
PHP bestand
<?php
$command = escapeshellcmd("python /var/www/html/test/var.py");
$output = shell_exec($command);
echo $output."<br>";
echo "php_works";
?>
Als ik het Python bestand op de server uitvoer werkt het zoals voorzien
------------------------------------------------------
xxx@pi:/var/www/html/test $ python var.py
op scherm
"dit is een string"
--------------------------------------------------------
In de browser komt echter op het scherm het volgende:
----------------------------------
op scherm "dit is een string"
php_works
-------------------------------
Waarom wordt die "new line" niet geprint?
Het grootste probleem zit hem echter bij de module serial.
Als ik de commentaar voor de "import serial" in het python bestand weg haal komt er niets meer in de browser.
---------------
php_works
-----------------
Wat kan hier het probleem zijn?
Python versie: 3.9.2
heb op de server ook al volgende gedaan
pip3 uninstall serial
pip3 uninstall pyserial
pip3 install pyserial
Wie kan helpen?
Dank u
Herman
...