I am trying to execute grep from php and print out the result. Normally in perl, I would do this:
open (SEARCH, "grep stuff *.html |");
while ($line = <SEARCH>) {
print $line;
}
close (SEARCH);
In PHP, I did this:
$fp = popen ("grep stuff *.html", "r");
while (!feof ($fp)) {
$buffer = fgets($fp, 4096);
echo $buffer;
}
pclose ($fp);
Both worked, except the perl version took less than 1 second to complete, while the PHP version took 30 seconds to complete. What did I do wrong?