RE: [PHP] email a file after the file is x lines long
| From: | Don Read | Date: | Sat, 07 Jul 2001 03:05:28 +0000 |
| Subject: | RE: [PHP] email a file after the file is x lines long | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56596@lists.php.net to get a copy of this message | ||
On 06-Jul-01 Jerry Lake wrote:
> Is it possible the set a script
> to email a file after it becomes so many lines
> long ? I have an email address that accepts
> only catalog requests and I'd like to be able
> to have a complete list mailed to me instead of
> doing it one at a time.
>
$fname='catrequest.log';
$fdone=$fname .'.tst';
unlink($fdone);
link($fname, $fdone);
unlink($fname);
$cmd="/usr/bin/wc -l fdone";
$p=popen($cmd, 'r');
if ($p) {
$lines=fgets($p,256);
if ( ($lines +0) > 10) {
/usr/bin/mail -s "Catalog Requessts" me@domain.com < $fdone;
} else {
/bin/cat $fdone >> $fname;
}
pclose($p);
}
`
Regards,
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.