If the problem with the output prints python script.

There is a linux server on which the web \ ssh \ php admin is raised and so on.

Posted web muzzle on html + php + js.

There is also a python3 script that performs some manipulations on the linux server and returns the prints that I need (traces and pings).

Actually I want to make it possible to launch this script from the web of the muzzle (at the moment it works through cli), the idea is as follows: 1) in the web form, the user selects the necessary parameters 2) then these parameters go to a variable (concat string). 3) the variable is sent to shell_exec to the server as a command. 4) I want to return the result to the web either directly in real time or through a file.

What has been achieved so far:

<script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// код для IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// код для IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","myout.txt",true); //используем АСИНХРОННУЮ передачу xmlhttp.send(); } </script> <button type="button" onclick="loadXMLDoc()">Обновить</button> <pre><div id="myDiv"><p>Для загрузки последнего результата нажмите "обновить"</p></div></pre> 

This allowed me to open the file on the web, and update it as my python script executes. The problem is that it works fully (it writes all printouts to the file) only if I run the python script via the CLI (-u disable buffering in order to update the result as the script runs - it takes about two minutes): python3 - u example.py ping node service 10.93.98.1,10.93.98.65> myout.txt

In the case of launch via the web, only one line is output to the file! Please help me figure out why, with the same launch commands, the output is different. As if my conclusion hangs.

Can someone tell me a more convenient method for my situation.

    0