Re: print sybase system stored procedure output to filehandle
- From: "Brian McCauley" <nobull67@xxxxxxxxx>
- Date: 14 Oct 2006 01:41:55 -0700
On Oct 13, 3:39 am, peter.br...@xxxxxxxxxxxxxx wrote:
Hi - is there a simple way to redirect the output from a Sybase system
stored proc [sp_recompile] to an open filhandle - currently the output
- 'Each stored procedure and trigger that uses table 'xxxxx will be
recompiled the next time it is executed.' - is printed on the console.
As I understand the DBI API there's no concept of the database
operations having a STDOUT or a STDERR, the only things that database
operations can return are a single rowset or an exception (error
string).
However there are tricks you can use in Perl to capture STDERR and/or
STDOUT from subprocesses and black-box Perl subroutines. Exactly which
would work here would depend on the implementation of DBD::Sybase.
I don't use DBD::Sybase but I'm going to guess that the string you are
seeing is being output to the current filedescriptor 2 directly by the
sybase client library.
If this is the case you can capture in using something like
#!perl
use strict;
use warnings;
use AtExit;
use IO::Handle;
open my $log, '>', 'log.log' or die $!;
{
open my $save_STDERR, '>&', *STDERR;
my $restore_STDERR = AtExit->new( sub {
open STDERR, '>&', $save_STDERR;
});
$log->flush; # Subprocess unbuffered so avoid dissordered o/p
open STDERR, '>&', $log;
system 'xxx'; # Subprocess that will error
# $restore_STDERR goes out-of-scope and puts back the original
STDERR
}
__END__
Of course it could be that DBD::Sybase is writing the output in some
other way in which case this won't help. For example if it forked-off a
helper process as soon as you open the filehandle and then wrote to the
fd 2 of that process you've have a somewhat harder time getting hold of
the outout corresponding to a given DBI transaction.
.
- References:
- print sybase system stored procedure output to filehandle
- From: peter . brown
- print sybase system stored procedure output to filehandle
- Prev by Date: Re: Sorting and moving files to dir for DVD burn
- Next by Date: Re: FAQ 4.36 How can I expand variables in text strings?
- Previous by thread: print sybase system stored procedure output to filehandle
- Next by thread: Data inheritence with classes in Perl
- Index(es):
Relevant Pages
|