RE: [PHP] Search for keyword in txt file
Greetings, Sorry for the delay in responding to your posting, I have been grappling with your suggestion for a while and still things are not working out. I have included all my code below and seek your advice.. As it stands, the resultant HTML page prints out the content of each file, but it puts it all in the right table row, as opposed to splitting it up for each row(file).also, my code, when viewed in vim, is all in blue after inserting the $result string you gave me. By taking out the * at the end of your statement, it reverts back to showing things in the proper colours, but the page is blank with the exception of the table formatting I have tried a lot of different things with your code but am now ready to start kicking the cat out of frustration. === ?php if ($handle = opendir('logs')) { echo Directory handle: $handle.'br'; echo 'table border=1' ; echo 'tr'; echo 'tdcenterbfont size=3 color=navyLog Files on '.$HTTP_SERVER_VARS['HTTP_HOST'] .'/td/center/b/font'; echo 'tdcenterbfont size=3 color=navyCreated/td/center/b/font'; echo '/tr'; { // Loop over the directory - while (false !== ($file = readdir($handle))) echo $file . 'br'; $result= `grep -n Started logs/*` ; //Take out upper directory pointers if ($file != . and $file != ..) //Start filename insertion-- { echo 'trtdfont size=2a href=/logs/'.$file.'' . $file . '/td/font/a'. 'td' . $result . 'br' . '/td'; } } echo '/tr'; echo '/table'; closedir($handle); } ? Thanks for taking the time to assist on this one. Chris On Fri, 2003-03-07 at 12:38, Ernest E Vogelsinger wrote: At 11:36 07.03.2003, Chris Blake said: [snip] Ok, it`s not that easy..here`s my code...I wanna search all the files in the logs directory and for each file found I want it to search for the word started and print that line into a table row. I will probably need to do like a for each loopbut where do I insert it ? [snip] In case you're _not_ in safe mode: $result = `grep -n started logs/*`; -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? [ OK ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search for keyword in txt file
Re my earlier post... I seem to have figured it out by changing the following lines : //=== { $result= `grep -n Started logs/$file` ; echo 'trtdfont size=2a href=/logs/'.$file.'' . $file . '/td/font/a'. 'td' . $result . '/td'; } // Now it works the way it`s supposed to.. On Fri, 2003-03-07 at 12:38, Ernest E Vogelsinger wrote: At 11:36 07.03.2003, Chris Blake said: [snip] Ok, it`s not that easy..here`s my code...I wanna search all the files in the logs directory and for each file found I want it to search for the word started and print that line into a table row. I will probably need to do like a for each loopbut where do I insert it ? [snip] In case you're _not_ in safe mode: $result = `grep -n started logs/*`; -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? [ OK ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Search for keyword in txt file
Greetings learned PHP(eople), What is the best method to search a text file for a specific string and return it to a form ? I`m not looking for you guys (and gals) to give me the answer, just point me in the right direction So long and thanks for all the fish.. -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? [ OK ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search for keyword in txt file
Dolphins are gone. ;) Here is your direction: preg_match(). If you need help with it (it can be compicated at first), ask. :) Niklas -Original Message- From: Chris Blake [mailto:[EMAIL PROTECTED] Sent: 7. maaliskuuta 2003 11:16 To: [EMAIL PROTECTED] Subject: [PHP] Search for keyword in txt file Greetings learned PHP(eople), What is the best method to search a text file for a specific string and return it to a form ? I`m not looking for you guys (and gals) to give me the answer, just point me in the right direction So long and thanks for all the fish.. -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? [ OK ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ### This message has been scanned by F-Secure Anti-Virus for Internet Mail. For more information, connect to http://www.F-Secure.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search for keyword in txt file
Ok, it`s not that easy..here`s my code...I wanna search all the files in the logs directory and for each file found I want it to search for the word started and print that line into a table row. I will probably need to do like a for each loopbut where do I insert it ? === ?php if ($handle = opendir('logs')) { echo Directory handle: $handle.'br'; echo 'table border=1' ; echo 'tr'; echo 'tdcenterbfont size=3 color=navyLog Files on '.$HTTP_SERVER_VARS['HTTP_HOST'] .'/td/center/b/font'; echo 'tdcenterbfont size=3 color=navyCreated/td/center/b/font'; echo '/tr'; { // Loop over the directory - while (false !== ($file = readdir($handle))) //Take out upper directory pointers first--- if ($file != . and $file != ..) //Start filename insertion-- { echo 'trtdfont size=2a href=/logs/'.$file.'' . $file . '/td/font/a'. 'td' . '/td'; } } echo '/tr'; echo '/table'; closedir($handle); } ? === Thanks Chris On Fri, 2003-03-07 at 11:21, Niklas Lampén wrote: Dolphins are gone. ;) Here is your direction: preg_match(). If you need help with it (it can be compicated at first), ask. :) Niklas -Original Message- From: Chris Blake [mailto:[EMAIL PROTECTED] Sent: 7. maaliskuuta 2003 11:16 To: [EMAIL PROTECTED] Subject: [PHP] Search for keyword in txt file Greetings learned PHP(eople), What is the best method to search a text file for a specific string and return it to a form ? I`m not looking for you guys (and gals) to give me the answer, just point me in the right direction So long and thanks for all the fish.. -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? [ OK ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ### This message has been scanned by F-Secure Anti-Virus for Internet Mail. For more information, connect to http://www.F-Secure.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? [ OK ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search for keyword in txt file
At 11:36 07.03.2003, Chris Blake said: [snip] Ok, it`s not that easy..here`s my code...I wanna search all the files in the logs directory and for each file found I want it to search for the word started and print that line into a table row. I will probably need to do like a for each loopbut where do I insert it ? [snip] In case you're _not_ in safe mode: $result = `grep -n started logs/*`; -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Search for keyword in txt file
You might want to use preg_match_all(). Here's a sample of getting whole row with a specified word in it: pre ? $file = This line should be found! This line is not important! If you see this, there is something wrong!!! This line should be found too! This is too much! Should this too? Yes, it should!; preg_match_all(/.*should.*/i, $file, $aMatches, PREG_PATTERN_ORDER); var_dump($aMatches); ? /pre Niklas -Original Message- From: Chris Blake [mailto:[EMAIL PROTECTED] Sent: 7. maaliskuuta 2003 12:36 To: Php-General Subject: RE: [PHP] Search for keyword in txt file Ok, it`s not that easy..here`s my code...I wanna search all the files in the logs directory and for each file found I want it to search for the word started and print that line into a table row. I will probably need to do like a for each loopbut where do I insert it ? === ?php if ($handle = opendir('logs')) { echo Directory handle: $handle.'br'; echo 'table border=1' ; echo 'tr'; echo 'tdcenterbfont size=3 color=navyLog Files on '.$HTTP_SERVER_VARS['HTTP_HOST'] .'/td/center/b/font'; echo 'tdcenterbfont size=3 color=navyCreated/td/center/b/font'; echo '/tr'; { // Loop over the directory - while (false !== ($file = readdir($handle))) //Take out upper directory pointers first--- if ($file != . and $file != ..) //Start filename insertion-- { echo 'trtdfont size=2a href=/logs/'.$file.'' . $file . '/td/font/a'. 'td' . '/td'; } } echo '/tr'; echo '/table'; closedir($handle); } ? === Thanks Chris On Fri, 2003-03-07 at 11:21, Niklas Lampén wrote: Dolphins are gone. ;) Here is your direction: preg_match(). If you need help with it (it can be compicated at first), ask. :) Niklas -Original Message- From: Chris Blake [mailto:[EMAIL PROTECTED] Sent: 7. maaliskuuta 2003 11:16 To: [EMAIL PROTECTED] Subject: [PHP] Search for keyword in txt file Greetings learned PHP(eople), What is the best method to search a text file for a specific string and return it to a form ? I`m not looking for you guys (and gals) to give me the answer, just point me in the right direction So long and thanks for all the fish.. -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? [ OK ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ### This message has been scanned by F-Secure Anti-Virus for Internet Mail. For more information, connect to http://www.F-Secure.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Chris Blake Office : (011) 782-0840 Cell : 083 985 0379 Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? [ OK ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ### This message has been scanned by F-Secure Anti-Virus for Internet Mail. For more information, connect to http://www.F-Secure.com/ ### This message has been scanned by F-Secure Anti-Virus for Internet Mail. For more information, connect to http://www.F-Secure.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php