I have a script which runs on a remote server , and this script generates a log file. I am calling this script on the server from my PHP command ( exec ) in which i give the credentials and the script name to call .
eg : exec( " ssh -i pemfile user@ipaddr ' python script.py' ")
this script generates a log file in the remote server which i want to be able to show on my webpage, to give the user an idea of how the script is working and its progress.
i want to mimic the following command , but to display on webpage not on terminal.
tail -f log_file.log
This is like a UI to call the script and also see the Log file, to know if the script was a success or not .
How do I go about doing this ? I am new to front end programming , please help.
You can do it in serveral ways.
For example, You can call the script from PHP and get the result using shell_exec function:
<?php
$command = escapeshellcmd('/usr/custom/test.py');
$output = shell_exec($command);
echo $output;
?>
Then, you will have to process the result to generate a view on your website.
Another way is to generate the file on a path in your server where our website has read permissions. For example, using fgets
Regards.