Setting environment variables
Export perl5lib=:/redhat/perl/lib64/perl5
Installing DBI
tar -xzvf DBI-1.631.tar.gz
cd DBI-1.631
perl Makefile.PL PREFIX=/redhat/perl
make
make test
make install
Installing DBD
tar -xzvf DBD-Sybase-1.15.tar.gz
cd /redhat/mahy/DBD-Sybase-1.15
perl Makefile.PL MP_AP_PREFIX=/redhat/sybase/OCS-15_0/perl PREFIX=/redhat/perl
make
make test
make install
Script:
#!/usr/bin/perl
use strict;
use POSIX qw(strftime);
use DBI;
my $dbh = DBI->connect(‘dbi:Sybase:server=TESTDB;charset=cp936‘,‘USERTEST‘,‘USERTEST‘)|| die "Database connection not made: $DBI::errstr";
my $test_sql = qq{
SELECT count (*) AS num_a,
sum (column_2) AS num_b from TEST_DATA
};
my $sth = $dbh->prepare( $test_sql );
my ($num_a,$num_b);
$sth->execute();
$sth->bind_columns( \$num_a, \$num_b);
while( $sth->fetch() ) {
print $num_a;
print $num_b;
}
$sth->finish();
$dbh->disconnect();
Summarize:
Many articles are installed by default as the root user
In fact, production environment is generally non-root users to install software, easy to generate a variety of resource permissions issues
There is a basic idea for solving the permissions environment problem, which is to specify the installation parameters and set the environment variables
Environment variables are mostly paths
Perl Operation Sybase