0

First of all, let me thank you for your time and knowledge sharing, I'm kind of an ignorant in trems of perl modules

I have a 64bit ubuntu Server 12.04, with Perl version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi and CPAN exploration and modules installation (v2.10).

I'm trying to use a perl script accessing a Microsoft SQL Server and I'm having a really hard time upon the DBD::Sybase module

When I try to install DBD::Sybase CPAN tells me it's already installed:

cpan[1]> install DBD::Sybase
Reading '/root/.cpan/Metadata'
  Database was generated on Wed, 29 Apr 2015 14:53:21 GMT
DBD::Sybase is up to date (1.15).

I also find multiple Sybase.pm files on my filesystem, some of them are under Perl path

root@server:# find /* -name Sybase.pm
/home/usriten/download/DBD-Sybase-1.15/Sybase.pm
/root/.cpan/build/DBD-Sybase-1.15-TtUI0T/Sybase.pm
/root/.cpan/build/DBD-Sybase-1.15-kNqdf7/Sybase.pm
/root/.cpan/build/DBD-Sybase-1.15-rZgcTa/Sybase.pm
/usr/local/lib/perl/5.14.2/Sybase.pm
/usr/local/lib/perl/5.14.2/DBD/Sybase.pm
/usr/local/lib/perl/5.14.2/DBI/Sybase.pm

But when I try to run my script it returns an error on a line that calls 'if ($self->{handle} = DBI->connect('

# ./check_mssql_health --hostname <MSSQL_Server_IP> --username <SQL_User> --password <Pass> --mode connection-time
mode connection-time
CRITICAL - cannot connect to <MSSQL_Server_IP>. install_driver(Sybase) failed: Can't locate loadable object for module DBD::Sybase in @INC (@INC contains: . /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl) at (eval 10) line 3
Compilation failed in require at (eval 10) line 3.
Perhaps a module that DBD::Sybase requires hasn't been fully installed
 at ./check_mssql_health line 3192

I've already spent a lot of time scavenging posts but I did not find a solution or at least one I could understand and Implement.

Best regards, Sebastião

Jim Davis
  • 5,241
  • 1
  • 26
  • 22
  • 1
    "Can't locate loadable object for module DBD::Sybase" is not the same thing as Can't locate DBD::Sybase. It's looking for a loadable library that might not have installed on your computer. The .pm file tells you that the "wrapper" code is there, but it doesn't tell you the native code is there which is loaded to do the c-level operations. – Axeman Apr 29 '15 at 16:58
  • 1
    Do you really have a path `.../DBI/Sybase.pm` [sic]? I don't know Sybase per se, but it's unusual for drivers to install under `DBI/` rather than under `DBD/` Perhaps someone manually botched your DBD-Sybase install. – pilcrow Apr 29 '15 at 17:00
  • In an act of desperation I've copied the Sybase.pm to the DBD/, I can remove that .pm but it does not make a difference (I've tried it) – Sebastião Burnay Apr 29 '15 at 17:08

3 Answers3

4

When I try to install DBD::Sybase CPAN tells me it's already installed:

That simply means it found a DBD/Sybase.pm. No tests are performed; the module isn't even loaded.

In an act of desperation I've copied the Sybase.pm to the DBD/

That's the cause of the error you're asking about. Perl is finding the .pm you copied over, but not the other files created as part of the installation process.

Delete the files you created[1], then install the module properly (e.g. using your system's package manager if it has one, or cpan DBD::Sybase if it doesn't).


  1. You appear to have created at least the following files:

    • /usr/local/lib/perl/5.14.2/Sybase.pm
    • /usr/local/lib/perl/5.14.2/DBD/Sybase.pm
    • /usr/local/lib/perl/5.14.2/DBI/Sybase.pm
ikegami
  • 367,544
  • 15
  • 269
  • 518
  • You were right, I've removed the copied files and reinstalled the Sybase with sudo apt-get install --reinstall libdbd-sybase-perl --force-yes -y – Sebastião Burnay Apr 30 '15 at 09:22
2

I got it working with a different setup.

Don't use DBD::Sybase, but install freetds, unixodbc, and then DBD::ODBC. In the freetds.conf file set the appropriate parameters. Mine looks like this

[myMSSL]
        host = 111.22.33.44
        port = 1433
        tds version = 7.2
        client charset = UTF-8

and /etc/odbc.ini

[mySQSL_mydb]
APP = unixodbc
Description     = Database mydb on myMSSQL
Driver          = TDSdriver
Server          = myhost
Database        = mydb
Port            = 1433
#Trace           = No

I think these are the packages that you need.

  • libdbd-freetds - Freetds database server driver for libdbi
  • tdsodbc -ODBC driver for connecting to MS SQL and Sybase SQL servers
  • freetds-bin - FreeTDS command-line utiliti

ALternatively, see also this post: Using Ubuntu, how do I install DBD::Sybase from CPAN?

(and some others, e.g this one: Access SQL Server from Solaris)

Community
  • 1
  • 1
knb
  • 9,138
  • 4
  • 58
  • 85
0

I would try and install it via apt

sudo apt-get install libdbd-sybase-perl -y

I've found CPAN to sometimes miss dependencies.

Ed Dunn
  • 1,152
  • 3
  • 11
  • 27