From: "Mitchell, Louise M" <[EMAIL PROTECTED]>
> In an earlier post inquiring about how to get the results ( such as
> from a backup or dbcc ), rather than rows, the response pasted below
> indicated a solution.... however, when I try this, I find that the
> actual results are returning in STDERR, not in the variable $text....

That's strange. It does work for me.

> In my code, I redirect STDERR to a file, as well as STDOUT... 
> printing the variable always prints a null string... while the file
> containing the STDERR always has the results...
> 
> This is the case if it's an error ( I forced one for a backup command
> )... or if it's just results ( I ran a simple dbcc checkdb )...

Could you post a small complete script that shows this problem?

This is the exact code I use (except the username&password of 
course;)

sub DBCC {
        my $database = shift();
        my $text = '';

        my $dbh = DBI->connect('dbi:ODBC:jobodbc2', 'uid', 'pwd',
                {PrintError => 0,RaiseError => 1,LongReadLen => 65536,
                odbc_async_exec => 1,
                odbc_err_handler => sub {
                                my ($state, $msg) = @_;
                                # Strip out all of the driver ID stuff
                                $msg =~ s/^(\[[\w\s]*\])+//;
                                $text .= $msg."\n";
                                return 0;
                        }
                });

        my $sth = $dbh->prepare("dbcc CHECKDB ('$database')");
        $sth->execute;
        $dbh->disconnect();

        return $text;
}

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery

Reply via email to