Hi folks
Ronan here. Just joined the list. I do PHP / MYSQL / GD / HTML / JavaScript / Flash
stuff, building db driven sites, content management systems, etc. I also use PHP as a
scripting langauge on my servers - its generally great.
However I have a little problem which someone might have come across or be able to
shed some light on. I want to pipe logs directly from apache into mysql. At the
moment I can do this using a perl script that does this sort of thing:-
<script>
#!/usr/bin/perl
[ DB CONNECTIONS etc ]
while (<STDIN>) {
[ DO DB INSERTS HERE ]
}
[ DB OBJ CLOSURE etc ]
</script>
I'm doing this in PHP:-
<script>
#!/usr/bin/php -q
<?php
$fp = fopen("/dev/stdin","r");
$inputfp = fopen("./input.txt","a");
function write_input($input, $inputfp) {
[ DB INSERTS HERE ]
}
$input = fread($fp,4096); // 4096 arbitrary value for testing
write_input($input,$inputfp);
fclose($inputfp);
fclose($fp);
?>
</script>
Works great if I manually pipe from ls or something
(ie: ls ~/ | phplog.php) but nothing happens when piping from apache. I reckon that
the problem lies in the file pointer reading - perl seems to keep the pointer (ie:
pipe) open while php seems to close the pipe after each fread().
Any clues ???
Cheers
--
Ronan
e: [EMAIL PROTECTED]
t: 01903 739 997
w: www.thelittledot.com
The Little Dot is a partnership of
Ronan Chilvers and Giles Webberley
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php