#!/usr/bin/perl # Copyright 2004 Jerzy Wachowiak use strict; use warnings; use DBI; use Getopt::Std; # Option retrival getopts( "msht:d:u:p:" ); our ( $opt_m, $opt_s, $opt_t ); our( $opt_d, $opt_u, $opt_p, $opt_h ); unless ( $opt_m or $opt_s or $opt_t or $opt_h or $opt_d ){ $opt_h = 1 }; if ( defined( $opt_h ) ){ print <1, RaiseError=>1 ); my $dbh = DBI->connect( $DBIdriver.$database, $DBIuser, $DBIpassword, \%attr ); # Main body: if ( !defined( $opt_m ) and !defined( $opt_s ) ){ $opt_m = $opt_s = 1 }; my ( $sqlcommand, $sth, @row ); # Option show statistics: if ( $opt_s ){ $sqlcommand = "select * from statistics where thread = '$opt_t' "; $sth = $dbh->prepare( $sqlcommand ); $sth->execute(); while ( @row = $sth->fetchrow_array() ) { print join("; ", @row), "\n" } } # Option show messages if ( $opt_m ){ $sqlcommand = "select * from messages where thread = '$opt_t' "; $sth = $dbh->prepare( $sqlcommand ); $sth->execute(); no warnings; while ( @row = $sth->fetchrow_array() ) { print join("; ", @row), "\n" } } $dbh->disconnect(); exit 0