----- Original Message ----- From: "Oliver Hankeln" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 17, 2004 9:29 AM Subject: Re: [PHP] Read Last Lines of a Text File
> Scott Miller wrote: > > >>>I've changed my script to the following: > >>> > >>><?php > >>> > >>>$file ="/var/log/radius.log"; > >>> > >>>$fp = popen("/usr/bin/tail -$limit $file", 'r'); > >>>if (! $fp ) { > >>> echo 'unable to pipe command'; > >>>} > >>>while (!feof($fp) ) { > >>> $line = fgets($fp); > >>> print $line; > >>>} > >>>?> > >>> > >>>And now get the following errors: > >>> > >>>Warning: Wrong parameter count for fgets() in /var/www/html/logs2.php on > >>>line 10 > >>> > >>>I get this over and over and over (like it's producing the error once > > > > per > > > >>>line in the log file). > >> > >>prior to PHP 4.2 you had to use a second parameter for fgets. This > >>parameter is the maximum length per line to read. > >>$line = fget($fp,4096); > >>will probably work. > >> > >>HTH, > >>Oliver > > > > > > Changed that line as shown above, and now get the following error: > > > > Fatal error: Call to undefined function: fget() in /var/www/html/logs2.php > > on line 11 > > Sorry. I mean fgets ... > That worked perfectly - now I at least get this: ==> standard input <== ==> /var/log/radius.log <== Thu Jun 17 09:21:01 2004: Auth: Login OK: [flasht999] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:22:22 2004: Auth: Login OK: [crbm] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:22:23 2004: Auth: Login OK: [tleec] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:23:19 2004: Auth: Login OK: [ziegen] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:23:24 2004: Auth: Login OK: [ziegen] (from nas 10.1.4.21/S0) socket 0 (0 sec) Thu Jun 17 09:23:42 2004: Auth: Login OK: [indiantrails] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:24:38 2004: Auth: Login OK: [kdglover] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:25:39 2004: Auth: Login OK: [altron] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:26:06 2004: Auth: Login OK: [altron] (from nas 10.1.4.21/S0) socket 0 (0 sec) Thu Jun 17 09:26:37 2004: Auth: Login OK: [nc3] (from nas 10.1.4.21/S0) socket 0 (0 sec) Now, how can I force a \n; to make it look like this: ==> standard input <== ==> /var/log/radius.log <== Thu Jun 17 09:21:01 2004: Auth: Login OK: [flasht999] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:22:22 2004: Auth: Login OK: [crbm] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:22:23 2004: Auth: Login OK: [tleec] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:23:19 2004: Auth: Login OK: [ziegen] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:23:24 2004: Auth: Login OK: [ziegen] (from nas xx.xx.xx.xx/S0) socket 0 (0 sec) Thu Jun 17 09:23:42 2004: Auth: Login OK: [indiantrails] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:24:38 2004: Auth: Login OK: [kdglover] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:25:39 2004: Auth: Login OK: [altron] (from nas Cisco AS5300/S0) socket 0 (0 sec) Thu Jun 17 09:26:06 2004: Auth: Login OK: [altron] (from nas xx.xx.xx.xx/S0) socket 0 (0 sec) Thu Jun 17 09:26:37 2004: Auth: Login OK: [nc3] (from nas xx.xx.xx.xx/S0) socket 0 (0 sec) Thanks, Scott -- Outgoing mail is certified Virus Free. Checked by AVG Anti-Virus (http://www.grisoft.com). Version: 7.0.251 / Virus Database: 263.3.2 - Release Date: 6/15/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php