Re: Silencing NOTICEs in Perl Pg

Поиск
Список
Период
Сортировка
От David Wheeler
Тема Re: Silencing NOTICEs in Perl Pg
Дата
Msg-id 7B2DC566-BBAF-11D6-B671-0003931A964A@wheeler.net
обсуждение исходный текст
Ответ на Re: Silencing NOTICEs in Perl Pg  (Bruno Wolff III <bruno@wolff.to>)
Ответы Re: Silencing NOTICEs in Perl Pg
Re: Silencing NOTICEs in Perl Pg
Re: Silencing NOTICEs in Perl Pg
Список pgsql-admin
On Thursday, August 29, 2002, at 01:02  PM, Bruno Wolff III wrote:

> On Thu, Aug 29, 2002 at 12:17:16 -0700,
>   David Wheeler <david@wheeler.net> wrote:
>> BTW, I missed the beginning of this thread, but based on the subject,
>> I'd sure like to find out if there's a simple way to suppress NOTICEs
>> using DBI/DBD::Pg. I've tried a number of tricks, but short of closing
>> STDOUT and STDERR in my Perl script, I've not found a way to do it.
>> PrintError => 0 doesn't do the trick.
>
> I do the following before doing anything with the database:
> open(OLDERR, '>&STDERR');
> close(STDERR);
> open(STDERR, '>/dev/null');

Thanks for the suggestion. Unfortunately, that doesn't allow me to
filter out just the NOTICEs, and let everything else be printed. The
solution I've come up with, for those who are interested, is either
this:

open STDERR, "| perl -e 'while (<>) { print unless /^NOTICE:  / }'"
   or die "Cannot pipe STDERR: $!\n";

Or this:

open STDERR, "| grep -v '^NOTICE:  '"
   or die "Cannot pipe STDERR to grep\n";

The former will be more portable, since we already know we have Perl ;-)

Thanks for the help!

David

--
David Wheeler                                     AIM: dwTheory
david@wheeler.net                                 ICQ: 15726394
http://david.wheeler.net/                      Yahoo!: dew7e
                                                Jabber: Theory@jabber.org


В списке pgsql-admin по дате отправления:

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Some timestamp problems
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Silencing NOTICEs in Perl Pg