#!/usr/bin/perl
##########################################################################
# Servertest.pl
##########################################################################
# -----------------------------------------------------
# Check that all of the required modules can be located
# ---------------------------------
# Let's see what our environment is
if (!$ENV{'SERVER_SOFTWARE'}) {
$newline = "\n";
$dbimodule = "ftp.cpan.org/pub/perl/CPAN/modules/by-module/DBI/DBI-1.08.tar.gz";
$mysqlmodule = "ftp.cpan.org/pub/perl/CPAN/modules/by-module/Mysql/Msql-Mysql-modules-1.2017.tar.gz";
$datadumper = "ftp.cpan.org/pub/perl/CPAN/modules/by-module/Data/Data-Dumper-2.10.tar.gz";
$datashowtable = "ftp.cpan.org/pub/perl/CPAN/modules/by-module/Data/Data-ShowTable-3.3.tar.gz";
}
else {
print "Content-type: text/html\n\n";
$newline = "
";
$dbimodule = "ftp://ftp.cpan.org/pub/perl/CPAN/modules/by-module/DBI/DBI-1.08.tar.gz";
$mysqlmodule = "ftp.cpan.org/pub/perl/CPAN/modules/by-module/Mysql/Msql-Mysql-modules-1.2017.tar.gz";
$datadumper = "ftp.cpan.org/pub/perl/CPAN/modules/by-module/Data/Data-Dumper-2.10.tar.gz";
$datashowtable = "ftp.cpan.org/pub/perl/CPAN/modules/by-module/Data/Data-ShowTable-3.3.tar.gz";
}
# --------------------------------------
# Check for the required version of PERL
eval "require 5.004";
print "Checking PERL version...";
if ($@) {
print "$newline"."This program requires at least PERL version 5.004.$newline";
exit;
}
print " OK$newline";
# -------------
# Check for DBI
print "Checking for DBI...";
eval "use DBI";
if ($@) {
print "$newline"."The DBI module could not be located. You will need to grab this module from $dbimodule and install it.$newline";
exit;
}
print " OK$newline";
use DBI;
# --------------------------
# Check for the mysql driver
print "Checking for the availabe drivers...";
@drivers = DBI ->available_drivers;
$SIZE = @drivers;
for ($i=0;$i<$SIZE;$i++) {
print "$drivers[$i]\n";
if ($drivers[$i] =~/mysql/) {
$mysql = 1;
}
}
print " OK$newline";
# ---------------------
# Check for data::dumper
print "Checking for Data::Dumper...";
eval "use Data::Dumper";
if ($@) {
print "$newline"."Could not find Data::Dumper. You will need to grab this module from $datadumper and install it.$newline";
exit;
}
print " OK$newline";
# -------------------------
# Check for data::Showtable
print "Checking for Data::ShowTable...";
eval "use ShowTable";
if ($@) {
print "$newline"."Could not find Data::Showtable. You will need to grab this module from $datashowtable and install it.$newline";
exit;
}
print " OK$newline";
print "$newline $newline";
print qq~
It looks like all of the required modules are in place. The only other required component is a SQL server. We develop on a mySQL database, but also support PostgreSQL and Oracle.
~;