Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

'grep' a file - output to browser not working

 
   Database Help (Home) -> PHP RSS
Next:  Why is server starting on 0.0.0.0:3000?  
Author Message
Phil

External


Since: Oct 31, 2007
Posts: 1



(Msg. 1) Posted: Wed Oct 31, 2007 11:45 pm
Post subject: 'grep' a file - output to browser not working
Archived from groups: comp>lang>php (more info?)

I cannot figure why this works fine at the command-line of the linux
server, but will not output anything to the browser, and no errors in
the error_log (syslog). The goal here is to have a page to enter a
search term and grep or zgrep pattern matches in the file (will be a
log file). Probably there is a better way to do this using php, but
this is what I was able to come up with using my limited php-
knowledge. Can anyone help me debug this?

<HTML>
<HEAD>
<TITLE>Search Log</TITLE>
</HEAD>
<BODY>

<form action="<?php echo "$_SERVER[PHP_SELF]"; ?>" method="POST">
<input type="text" name="sstr" value="" size="20" maxlength="30"/>
<input type="submit" value="Search!"/>
</form>

<?php
//$test=$_POST['sstr'];
$test="foo";

if (! empty($test))
{
$cmdstr = "grep -i $test <somefile>";
$fp = popen($cmdstr, 'r');
while ($buffer = fread($fp, 8096)) {
echo "<br><hr><pre>";
print($buffer);
echo "</pre>";
flush(); }
pclose($fp);
}
else
{ echo "Please enter a search-term and try again!"; }

?>
</BODY>
</HTML>

 >> Stay informed about: 'grep' a file - output to browser not working 
Back to top
Login to vote
Jerry Stuckle

External


Since: Aug 11, 2004
Posts: 3780



(Msg. 2) Posted: Wed Oct 31, 2007 11:45 pm
Post subject: Re: 'grep' a file - output to browser not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Phil wrote:

P.S. Please don't top post. Thanks.
>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.RemoveThis@attglobal.net
==================

 >> Stay informed about: 'grep' a file - output to browser not working 
Back to top
Login to vote
Jackie Silva

External


Since: Oct 31, 2007
Posts: 32



(Msg. 3) Posted: Thu Nov 01, 2007 12:25 am
Post subject: Re: 'grep' a file - output to browser not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

top posting is fine. it's really a matter of individual preference. here are
some posting tips for you:

http://www.robertnyman.com/2007/03/29/posting-styles-and-why-top-posti...is-just
http://en.wikipedia.org/wiki/Posting_style

and the quote in your message is missing completely.


"Jerry Stuckle" wrote in message

> Phil wrote:
>
> P.S. Please don't top post. Thanks.
>>
>
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex DeleteThis @attglobal.net
> ==================
>
 >> Stay informed about: 'grep' a file - output to browser not working 
Back to top
Login to vote
Captain Paralytic

External


Since: Nov 08, 2007
Posts: 119



(Msg. 4) Posted: Thu Nov 01, 2007 5:39 am
Post subject: Re: 'grep' a file - output to browser not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 1 Nov, 05:25, "Jackie Silva" wrote:
> top posting is fine. it's really a matter of individual preference. here are
> some posting tips for you:
>
> http://www.robertnyman.com/2007/03/29/posting-styles-and-why-top-post....ttp://e
>
> and the quote in your message is missing completely.
>
> "Jerry Stuckle" wrote in message
>
>
>
>
>
> > Phil wrote:
>
> > P.S. Please don't top post. Thanks.
>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck....RemoveThis@attglobal.net
> > ==================- Hide quoted text -
>
> - Show quoted text -

I have a posting tip for you.

Don't bother!
 >> Stay informed about: 'grep' a file - output to browser not working 
Back to top
Login to vote
Ivan Marsh

External


Since: Jan 14, 2008
Posts: 81



(Msg. 5) Posted: Thu Nov 01, 2007 10:38 am
Post subject: Re: 'grep' a file - output to browser not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Thu, 01 Nov 2007 00:25:07 -0500, Jackie Silva wrote:

> top posting is fine. it's really a matter of individual preference.

No... it's not.

If you top post you can assume your query will end up in a thread about
top posting rather than being answered... just as this thread has.

--
I told you this was going to happen.
 >> Stay informed about: 'grep' a file - output to browser not working 
Back to top
Login to vote
Rik Wasmus

External


Since: Jan 10, 2008
Posts: 568



(Msg. 6) Posted: Thu Nov 01, 2007 4:28 pm
Post subject: Re: 'grep' a file - output to browser not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Thu, 01 Nov 2007 06:25:07 +0100, Jackie Silva
wrote:

> top posting is fine. it's really a matter of individual preference. here
> are
> some posting tips for you:
>
> http://www.robertnyman.com/2007/03/29/posting-styles-and-why-top-posti...is-just

Yes, topposting is fine, and actually my preferred method, for email
(sometimes interleaved, though rarely). This however is usenet, not
personal email.
--
Rik Wasmus
 >> Stay informed about: 'grep' a file - output to browser not working 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Output differs between browser and console - This may be covered already, but I've yet to hit upon the search terms to find it... I'm running PHP v4.4.0 on a Windows 2000 Server (SP4) running IIS v5. A simple script I'm using is generating ODBC errors (not finding my tables) when I run the scrip...

Output an image directly at a particular position in the b.. - Is it possible to dynamically create an image (jpeg/gif/png) and output it directly at a particular coordinate position in the in browser window using PHP GD functions and HTML (if necessary)?

php/ajax file browser? - A client sends me this request: "add an AJAX hierarchical menu that emulates a graphical filesystem browser in order to inspect upload directories for validation purposes. There are several open source kits for this sort of thing, so it would on...

Want XML file to open in spreadsheet, not browser... how to? - I have a spreadsheet saved as an XML spreadsheet so I can manipulate it easier (and don't need COM). When I'm done, I want to display to the user. Currently, I'm using simple JavaScript in my PHP file: echo '<script type="text/javascript&quo...

something like grep - I'd like to open a directory and spider all the subdirectories and files. What is the php term for doing this? Seems like it should be here: http://us3.php.net/manual/en/ref.filesystem.php Perhaps I'm just having a bad day! Jeff
   Database Help (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]