Skip to content

Instantly share code, notes, and snippets.

@danvaly danvaly/extract-log.php
Last active May 23, 2018

What would you like to do?
Search and extract data from server log files
* Tools to process end extract log data from Proftpd.log files
* Ex: php extract.php -f ftp_in.log -s PUT-o ftp_out.log
$options = getopt("f:s:o:");
if (isset($options['f']) && isset($options['o']) && $options['s'] && strlen($options['s'])>0 ){
if (!file_exists($options['f'])){
die("Eroare: Nu am gasit fisierul pentru citire!");
$read = fopen($options['f'],"r");
$write = fopen($options['o'],'a');
if ($read && $write){
while (($line = fgets($read)) !== false) {
// process the line read.
if (isset($options['s']) ){
//detect string in line
if( stristr($line, $options['s']) ) {
fputs($write, $line);
fputs($write, $line);
die("Fisierele nu pot fi create.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.