Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:48:25

0001 #!/usr/bin/perl
0002 
0003 use warnings;
0004 use strict;
0005 $|++;
0006 use File::Basename;
0007 use Getopt::Long;
0008 
0009 my $usage = basename($0)." --source_connect  --dest_connect time \n".
0010     "Options:\n".
0011     "--source_connect  source connect string: user/pass\@db(required)\n".
0012     "--dest_connect    destination database: user/pass\@db(required) \n".
0013     "--help, -h        Print this message and exit\n";
0014 
0015 my $source_connect='' ;
0016 my $dest_connect='' ;
0017 my $help = 0;
0018 GetOptions('source_connect=s' => \$source_connect,
0019        'dest_connect=s' => \$dest_connect,
0020        'help|h' => \$help );
0021 if ($help) {
0022     print "$usage";
0023     exit;
0024 }
0025 
0026 my $time = shift @ARGV;
0027 
0028 die "Must provide polling time interval in second."  unless $time;
0029 
0030 my $conn_source = "sqlplus -SL ${source_connect}";
0031 my $conn_dest = "sqlplus -SL ${dest_connect}";
0032 
0033 print "Opening pipes to sqlplus...";
0034 open SOURCE, "| $conn_source >> source_poll.txt" or die $!;
0035 print SOURCE "set serveroutput on;\nset echo off;\n";
0036 
0037 open DEST, "| $conn_dest >> dest_poll.txt" or die $!;
0038 print DEST "set serveroutput on;\nset echo off;\n";
0039 print "Done.\n";
0040 
0041 print "Beginning polling every $time s, use Ctl-c to stop\n\n";
0042 
0043 while (1) {
0044     print SOURCE "call poll_db();\n";
0045     print DEST "call poll_db();\n";
0046     sleep($time);
0047     print `echo -n`; # I don't know why, but this program doesn't work with out this line
0048 }
0049 
0050 END {
0051     print "Closing pipes.\n";
0052     close SOURCE;
0053     close DEST;
0054 }