標籤:
設定環境變數
export PERL5LIB=:/redhat/perl/lib64/perl5
安裝DBI
tar -xzvf DBI-1.631.tar.gzcd DBI-1.631perl Makefile.PL PREFIX=/redhat/perlmakemake testmake install
安裝DBD
tar -xzvf DBD-Sybase-1.15.tar.gz cd /redhat/mahy/DBD-Sybase-1.15perl Makefile.PL MP_AP_PREFIX=/redhat/sybase/OCS-15_0/perl PREFIX=/redhat/perlmakemake testmake install
指令碼:
#!/usr/bin/perluse 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();
總結:
很多文章都預設以root使用者安裝
其實生產環境一般都是以非root使用者安裝軟體的,容易產生各種資源許可權問題
解決許可權環境問題有一個基本的思路,那就是指定安裝參數並且設定環境變數
環境變數多數是一些路徑
perl操作sybase