#!perl # package buildSplit; use strict; use Exporter (); use vars qw(@ISA @EXPORT); BEGIN { @ISA = qw(Exporter); @EXPORT = qw(&getData &doSQLdatasetOutput &doSQLgetDatasets); } 1; #----------------------------- sub getData { use DBI; use strict; # Read the database, username and password from a file # The file must be three lines with database, username and password # on separate lines. There must be no blank lines at the # end of the file. # my $dbname; # my $temp; # my $user; # my $password; # open (USERNAME,"test.user") || die "can't open file: $!"; # while (defined ($temp = )) # { # chomp $temp; # $dbname = $temp; # $user=; # chomp $user; # $password=; # chomp $password; # }; # close (USERNAME) || die "couldn't close file: $!"; open (OUT, ">-") || die "I/O error accessing STDOUT:$!"; # look for functionality arguments in the list of arguments # supported functionality arguments are # "--resplit=[column_name,streams]" resplit according to column_name, # omiting streams specified, e.g. ad # to omit streams a,d # "--compress=[compressed streams]" provide compressed output for streams # e.g., hj to provide compressed for h,j # first look for "--" arguments # print STDERR "before filtering options: @_ \n"; my $argument; my @optionNum; my @optionList; my @filteredArgs; foreach $argument (@_) { if ( $argument =~ /--/ ) { # print STDERR "located an argument $argument \n"; push @optionList, $argument; } else { push @filteredArgs, $argument; } } # print STDERR "after filtering options: @filteredArgs \n"; $main::resplit_column="NONE"; $main::compress_streams=" "; $main::resplit_omitstreams=" "; foreach $argument (@optionList) { if ($argument =~ /resplit/ ) { my @specs = split /[=\,]/,$argument,3; $main::resplit_column=$specs[1]; $main::resplit_omitstreams=$specs[2]; } if ($argument =~ /compress/ ) { my @specs = split /[=\,]/,$argument,3; $main::compress_streams=lc $specs[1]; } } # first argument is the stream_name_used flag $main::stream_name_used = shift @filteredArgs; # template file name my $template = shift @filteredArgs; # name and tag of the physics table and are passed in as arguments $main::phys_table = shift @filteredArgs; $main::phys_table_tag = shift @filteredArgs; print OUT "#Physics Table name and tag are: $main::phys_table, $main::phys_table_tag\n"; # Removed use of test.user for connecting to database, using the # cdf_reader login which is READ ONLY. Which database to connect # to is now passed in as an argument - KAT 10/17/00 my $dbname = shift @filteredArgs; my $user = "cdf_reader"; my $password = "reader"; # Hard wiring password and username for development database since # a cdf_reader which sees the trigger tables doesn't exist on cdfondev # $dbname = "cdfondev"; if ($dbname eq "cdfondev") { $user = "level3_trig_dev"; $password = "level3"; } # print STDERR "arguments are now : $dbname, $user, $password \n"; #note how connection specifies Oracle here, msql, mysql or any #other DBI driver will work exactly the same # $main::dbh = DBI->connect("dbi:Oracle:$dbname",$user,$password) || die "Error connecting $DBI::errstr\n"; #hard coded: connection to cdfofprd because filecatalog queries do not work on #cdfonprd used for the L3exe build # $main::dbh_ofprd = DBI->connect("dbi:Oracle:cdfofprd","cdf_reader","reader") || die "Error connecting $DBI::errstr\n"; my $myfile=$template; my $line; open(TEMPLATE, $myfile) or die "unable to open $myfile:$!"; while( $line =