#!/usr/bin/env perl

use strict;
use warnings;
use lib ('/usr/local/sitebuilder/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level');
use lib ('/usr/local/psa/lib/perl5/site_perl/5.8.8/mach');
use DBI;

sub ping() { 
    my $dbh;
	my $err;
	my $user = "root";
	my $password = "";
	
	$user = $ARGV[0] if $ARGV[0];
	$password = $ARGV[1] if $ARGV[1];
	
	$dbh = DBI->connect(
		"DBI:mysql:mysql:localhost:3306",
		$user,
		$password,
		{
			PrintError => 1,
			RaiseError => 0,
			AutoCommit => 0
		}
	);

	if ($DBI::err) {
		$err = $DBI::err;
	}
	else {
		$err = 0;
	}
	$dbh->disconnect() if $dbh;
	print $err . "\n";
	return ($err > 0);
}

exit (ping());

