I have a bash script that is execute in a function in a laravel Controller and I want to output the echos from within while the script is being executed. I tried this way but it does not work, it shows everything togheter after the script is executed.
public function execute_bash(command)
{
flush();
$fp = popen(command, "r");
while(!feof($fp))
{
// send the current file part to the browser
print fread($fp, 1024);
// flush the content to the browser
flush();
}
fclose($fp);
}
I do that with ajax
$.ajax({
data: parameters,
url: '/executeBash',
type: 'get',
beforeSend: function(){
console.log("executing...");
},
success: function(response){
console.log("success: %O", response);
},
error: function(response){
console.log("error: %O", response);
}
});
How can I achieve wath I want? Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire