MorganGreylock
Programmer
I am working on a web-based (cgi) script that will allow easy searching through hundreds of "logs" that are mounted on an NFS share. I already have the search part working, which basically does a grep out of the log directory. It returns an array which I display to the webpage. I then want the user to be able to click on the log file to view the whole log file. Preferably this would happen in the browser without any extra clicking, or file-type additions, etc. (I'm assuming that the people who might be using this are grumpy and hate extra steps, which is mostly true.)
For example, On the webpage they might see this:
(searching for term 'sudo')
/nfs/share/logs/001.log: added user smith2 to sudo rule
/nfs/share/logs/004.log: sudo stopped working for
/nfs/share/logs/010.log: then I told them to use visudo but
So in other words, the grep only returns the lines where that search string exists, and I want them to be able to view the entire log file. I have tried (using substr) to make an html href link of the log name, and the link is created, but clicking on it gets no result whatsoever.
I've tried prepending a "file://", and that doesn't work either. I need to make sure that any computer they are using this page on will work, ie not only ones that can directly see the /nfs/share mounts. (Make sense?)
Any suggestions on what I might try to get this working?
Below is the code I'm working with right now:
Thanks!
Notice I escaped the slashes in file:// although I'm not sure thats necessary here. Still learning.
For example, On the webpage they might see this:
(searching for term 'sudo')
/nfs/share/logs/001.log: added user smith2 to sudo rule
/nfs/share/logs/004.log: sudo stopped working for
/nfs/share/logs/010.log: then I told them to use visudo but
So in other words, the grep only returns the lines where that search string exists, and I want them to be able to view the entire log file. I have tried (using substr) to make an html href link of the log name, and the link is created, but clicking on it gets no result whatsoever.
I've tried prepending a "file://", and that doesn't work either. I need to make sure that any computer they are using this page on will work, ie not only ones that can directly see the /nfs/share mounts. (Make sense?)
Any suggestions on what I might try to get this working?
Below is the code I'm working with right now:
Thanks!
Code:
for ($i=0; $i<$num_results; $i++)
{
$logname = substr($output[$i], 0, 26);
$logentry = substr($output[$i], 27);
print "<a href=\"file:\/\/$logname\">$logname</a>";
print " -- $logentry <BR>";
}