#!/usr/bin/perl -w #/* Copyright (C) 2000-2005 MySQL AB # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Version 1.1 ####################### Includes ############################ use DBI; ####################### Globals ############################ my $m_host=''; my $m_port=''; my $m_user=''; my $m_pass=''; my $dbhM=''; ####################### Sub Pototypes ############################ sub CollectCommandPromptInfo; sub ConnectToDatabases; sub DisconnectFromDatabases; ######################## Program Main ########################### CollectCommandPromptInfo; while(1) { print "Connecting in $$...\n"; ConnectToDatabases; DisconnectFromDatabases; print "Disconnected in $$...\n"; } ###################### Collect Command Prompt Info ############# sub CollectCommandPromptInfo { ### Check that user has supplied correct number of command line args die "Usage:\n inout.pl < master pass>\n All 4 arguments must be passed. Use BLANK for NULL passwords\n" unless @ARGV == 4; $m_host =$ARGV[0]; $m_port = $ARGV[1]; $m_user = $ARGV[2]; $m_pass = $ARGV[3]; if ($m_pass eq "BLANK") { $m_pass = '';} } ###################### Collect Command Prompt Info ############# sub ConnectToDatabases { $dbhM = DBI->connect("dbi:mysql:database=test;host=$m_host;port=$m_port", "$m_user", "$m_pass") or die "Can't connect to Master Cluster MySQL process! Error: $DBI::errstr\n"; } sub DisconnectFromDatabases { $dbhM->disconnect or warn " Disconnection failed: $DBI::errstr\n"; }