Yeah! It's all about the libraries of freetds.
I exported all the libraries using LD_LIBRARY_PATH=/usr/local/freetds/lib
Now, I am able to use and execute some queries on this module. But, when I run sample cgi script, it's not going to execute.
Here is the sample code which I tried.
#!/usr/bin/perl
BEGIN
{
$ENV{'SYBASE'} = '/usr/local/freetds';
$ENV{'LD_LIBRARY_PATH'} = '/usr/local/freetds/lib';
}
use CGI;
use CGI::Carp;
use DBI;
my $cgi = new CGI();
print $cgi->header();
my $cgi = new CGI();
my $path='/opt/ash/netcool';
my $hostname="192.168.2.95";
my $portno="4100";
my $database_name="NCOMS";
my $db_username="root";
my $db_password="access";
print <<EOF;
<html>
<head>
<title>DBD Sybase Connection Check</title>
</head>
<body>
<form name="myform">
EOF
print "\nSyabse:$ENV{'SYBASE'}<br>LD_LIBRARY_PATH:$ENV{'LD_LIBRARY_PAT
+H'}<br>";
print "<h2>**********----->$dbh<-----**********</h2>";
my $dbh = DBI->connect("dbi:Sybase:host=$hostname;port=$portno;server=
+$database_name;",$db_username,$db_password) || warn "Database Connect
+ion
not made: $DBI::errstr";
print "<h2>**********$dbh**********</h2><br>";
print <<EOF;
<br>
</form>
</body>
</html>
EOF
and the corresponding output when I execute this sample code:
In console, without setting SYBASE=/usr/local/freetds and LD_LIBRARY_PATH=/usr/local/freetds/lib is
[root@station34 cgi-bin]# ./dbdsybase.cgi
Content-Type: text/html; charset=ISO-8859-1
<html>
<head>
<title>DBD Sybase Connection Check</title>
</head>
<body>
<form name="myform">
install_driver(Sybase) failed: Can't load '/usr/lib/perl5/site_perl/5.
+8.5/i386-linux-thread-multi/auto/DBD/Sybase/Sybase.so' for module DBD
+::Sybase: libct.so.4: cannot open shared object file: No such file or
+ directory at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader
+.pm line 230.
at (eval 8) line 3
Compilation failed in require at (eval 8) line 3.
Perhaps a required shared library or dll isn't installed where expecte
+d
at ./dbdsybase.cgi line 29
Syabse:/usr/local/freetds<br>LD_LIBRARY_PATH:/usr/local/freetds/lib<br
+><h2>**********-----><-----**********</h2>[root@station34 cgi-bin]#
In console, by setting SYBASE=/usr/local/freetds and LD_LIBRARY_PATH=/usr/local/freetds/lib is
[root@station34 cgi-bin]# ./dbdsybase.cgi
Content-Type: text/html; charset=ISO-8859-1
<html>
<head>
<title>DBD Sybase Connection Check</title>
</head>
<body>
<form name="myform">
Syabse:/usr/local/freetds<br>LD_LIBRARY_PATH:/usr/local/freetds/lib<br
+><h2>**********-----><-----**********</h2><h2>**********DBI::db=HASH(
+0x87e56cc)**********</h2><br><br>
</form>
</body>
</html>
On browser
Syabse:/usr/local/freetds
LD_LIBRARY_PATH:/usr/local/freetds/lib
**********-----><-----**********
which means that the part
my $dbh = DBI->connect("dbi:Sybase:host=$hostname;port=$portno;server=
+$database_name;",$db_username,$db_password) || warn "Database Connect
+ion not made: $DBI::errstr";
print "<h2>**********$dbh**********</h2><br>";
print <<EOF;
<br>
</form>
</body>
</html>
EOF
of the script is not executing due to connect statement.
Also, why $DBI::errstr is not printing here.
Thanks in advance.
|