So I kind of found the answer I was searching for, more like an alternative.
Somebody mentioned somewhere, something about cron scripts so, I did the following.
Step I:
sudo crontab -e
Enter 2
for nano editor
Add the following lines:
* * * * * lsof -i :80 > /home/shine/port80.txt
* * * * * lsof -i :3000 > /home/shine/port3000.txt
Note:The above lines of code will generate two text files containing port 80 & 3000 info in the current users' home directory every minute.
ctrl+o
, enter
, ctrl+x
to save and exit.
Step II:
In apache's www directory Create a php file with the following code.
<?php
$output80 = shell_exec("cat '/home/shine/reports/port80.txt'");
echo "<pre>$output80</pre>";
$output3000 = shell_exec('cat "/home/shine/reports/port3000.txt"');
echo "<pre>$output3000</pre>";
?>
This is the only way I can think of at this moment to make lsof work on a web page.