bhushanQA has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a script where in I have to connect to the sybase database I have written the script but getting below errors in execution:

DBI connect('server=172.20.24.157; database=PP_DB; interfaces=/opt/sybase/interfaces','sa',...) failed: OpenClient message: LAYER = (6) ORIGIN = (8) SEVERITY = (5) NUMBER = (1) Server 172.20.24.157, database Message String: ct_connect(): directory service layer: internal directory control layer error: There was an error encountered while binding to the directory service. at ./update_database.pl line 5

Below is the script:
#!/usr/bin/perl use strict; use DBI; my $dbh = DBI->connect( "DBI:Sybase:server=172.20.24.157; database=PP_ +DB; interfaces=/opt/sybase/interfaces","sa", "password" );

Can somebody guide me where it is going wrong ??

Replies are listed 'Best First'.
Re: Perl script to connect to sybase database
by Corion (Patriarch) on Jun 22, 2015 at 13:27 UTC
    directory service layer: internal directory control layer error: There + was an error encountered while binding to the directory service.

    This is an Sybase internal error. It should be documented in the documentation of Sybase, but maybe you can also contact Sybase and have them explain the problem. Does dbping detect the database?

      yes dbping is working fine. on some other machine the same is working
Re: Perl script to connect to sybase database
by graff (Chancellor) on Jun 23, 2015 at 01:44 UTC
    If I put (most of) the error message into a google search, the first hit I get (at an ibm.com site) tells me:

    This issue is caused by the Sybase Open Client being unable to find the database server name. This is typically provided in the Sybase client interfaces file. ... Sybase documentation states that the default location of the interfaces file is the directory pointed to by the $SYBASE environment variable. Please ensure that the interfaces file exists in this directory.

    ... which makes your situation look like a good candidate for shell environment problem. Modify your script slightly so that it prints (or stores in a temp file) the contents of %ENV; look at that output, and confirm that (a) the $SYBASE variable is set to some path, and (b) that path actually points to the expected data file.

Re: Perl script to connect to sybase database
by locked_user sundialsvc4 (Abbot) on Jun 22, 2015 at 14:24 UTC

    Okay, if “on some other machine this is working,” but not “here,” then this, to me, is pretty much a dead-giveaway that the problem most likely is not in Perl code.   Try running some other Sybase utility on this machine, to determine if this other program can (or, I predict, also cannot ...) connect.   The nature of the error message strongly suggests to me that there is some kind of configuration issue in the so-called “plumbing layers” that connect everything together ... not in the surface-layer software that is attempting to initiate a request.   Only after thoroughly exhausting that possibility would I return to looking at the [Perl].