On Fri, Jun 29, 2012 at 4:49 AM, Mihamina Rakotomandimby <mihamina@xxxxxxxxx> wrote: [snip!] > > Typically, a log line like: > Jun 29 11:24:10 dev5 sshd[12775]: Accepted password \ > for dev5 from 192.168.0.12 port 50544 ssh2 > [snip!] > So that I can: > > INSERT INTO ssh_activity \ > VALUES ('2012-06-29 11:24:10', '192.168.0.12') > > I just need help on the right regexp function to use. > Would you know some PHP/regexp tutorials for that? You could take the pattern-matching load off of PHP entirely if you used something along these lines. Just remember to adjust and clean up as necessary. <?php $ssh_entries = explode(PHP_EOL,trim(`tail /var/log/syslog | awk {'print $1,$2,$3 "|" $5 "|" $11'}`)); foreach ($ssh_entries as $s) { $l = explode('|',$s); // Remember to do whatever sanity necessary! $sql = "INSERT INTO ssh_activity VALUES('".$l[0]."','".$l[1]."','".$l[2]."')"; } ?> -- </Daniel P. Brown> Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php