And, to add, I’ve recently come across a new Microsoft ODBC driver for Linux.  
I haven’t tested it yet, but I can imagine it may address domain logins for 
example.  It’s on my todo list some day.

(I recently tested a different driver for OS X that allowed domain credentials 
— very cool…)

> On May 17, 2016, at 5:05 PM, Alexander Foken <alexan...@foken.de> wrote:
> 
> Hello,
> 
> I doubt DBD::Sybase is the best choice to connect to MS SQL Server. Sybase 
> and SQL Server are "relatives", but have diverged. You may have more luck 
> trying DBD::ODBC. See also 
> http://search.cpan.org/~mjevans/DBD-ODBC-1.52/FAQ#How_do_I_access_a_MS_SQL_Server_database_from_Linux/UNIX
>  
> <http://search.cpan.org/~mjevans/DBD-ODBC-1.52/FAQ#How_do_I_access_a_MS_SQL_Server_database_from_Linux/UNIX>?
> 
> Hope that helps
> 
> Alexander
> 
> On 15.05.2016 05:32, sumanth ramesh wrote:
>> Dear Experts,
>> 
>> I am new to perl and I really need your help. I need your help for a perl 
>> DBD:sybase module i am using.
>> 
>> I am trying to connect to a MS SQL Server from a linux server. Below are the 
>> details and the error message.
>> 
>> Request you to let me know how I can fix it. I will provide any more logs 
>> which you may require. For now, below are the details.
>> 
>> Thank you very much. Looking forward for your assistance.
>> 
>> 
>> Brief Description
>> I have freetds, DBI and DBD:Sybase installated. When i TSQL to a sql server 
>> is works fine, but when i try to connect form  a perl script it fails with 
>> the error "REquested server name not found". by testing i have noticed it 
>> may be using $HOME/interfaces file instead of freetds.conf file.
>> 
>> cat /etc/*release
>> 
>> Kernel Release: Red Hat Enterprise Linux 6.4
>> 
>> Kernel Architecture: x86_64
>> 
>> Packages Release: Red Hat Enterprise Linux Server release 6.5 (Santiago)
>> 
>> Red Hat Enterprise Linux Server release 6.5 (Santiago)
>> Red Hat Enterprise Linux Server release 6.5 (Santiago)
>> 
>> 
>> [sybase@1636541cllapp15 ~]$ perl -V
>> Summary of my perl5 (revision 5 version 10 subversion 1) configuration:
>> 
>>   Platform:
>>     osname=linux, osvers=2.6.18-402.el5, archname=x86_64-linux-thread-multi
>>     uname='linux x86-027.build.eng.bos.redhat.com 
>> <http://x86-027.build.eng.bos.redhat.com/> 2.6.18-402.el5 #1 smp thu jan 8 
>> 06:22:34 est 2015 x86_64 x86_64 x86_64 gnulinux '
>>     config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 
>> -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic 
>> -DDEBUGGING=-g -Dversion=5.10.1 -Dmyhostname=localhost 
>> -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dprefix=/usr 
>> -Dvendorprefix=/usr -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl5 
>> -Dsitearch=/usr/local/lib64/perl5 -Dprivlib=/usr/share/perl5 
>> -Darchlib=/usr/lib64/perl5 -Dvendorlib=/usr/share/perl5/vendor_perl 
>> -Dvendorarch=/usr/lib64/perl5/vendor_perl -Dinc_version_list=5.10.0 
>> -Darchname=x86_64-linux-thread-multi -Dlibpth=/usr/local/lib64 /lib64 
>> /usr/lib64 -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles 
>> -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog 
>> -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 
>> -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto 
>> -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto 
>> -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto 
>> -Dscriptdir=/usr/bin -Dusesitecustomize'
>>     hint=recommended, useposix=true, d_sigaction=define
>>     useithreads=define, usemultiplicity=define
>>     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
>>     use64bitint=define, use64bitall=define, uselongdouble=undef
>>     usemymalloc=n, bincompat5005=undef
>>   Compiler:
>>     cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing 
>> -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE 
>> -D_FILE_OFFSET_BITS=64',
>>     optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
>> -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic',
>>     cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe 
>> -fstack-protector -I/usr/local/include'
>>     ccversion='', gccversion='4.4.7 20120313 (Red Hat 4.4.7-14)', 
>> gccosandvers=''
>>     intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
>>     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
>>     ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', 
>> lseeksize=8
>>     alignbytes=8, prototype=define
>>   Linker and Libraries:
>>     ld='gcc', ldflags =' -fstack-protector'
>>     libpth=/usr/local/lib64 /lib64 /usr/lib64
>>     libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
>>     perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
>>     libc=, so=so, useshrplib=true, libperl=libperl.so
>>     gnulibc_version='2.12'
>>   Dynamic Linking:
>>     dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E 
>> -Wl,-rpath,/usr/lib64/perl5/CORE'
>>     cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall 
>> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
>> --param=ssp-buffer-size=4 -m64 -mtune=generic'
>> 
>> 
>> Characteristics of this binary (from libperl):
>>   Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
>>                         PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_BIT_ALL
>>                         USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
>>                         USE_PERLIO USE_REENTRANT_API USE_SITECUSTOMIZE
>>   Built under linux
>>   Compiled at Mar 13 2015 07:49:15
>>   %ENV:
>>     PERL5LIB="/usr/local/lib64/perl5:/usr/lib64/perl5"
>>   @INC:
>>     /usr/local/lib64/perl5
>>     /usr/lib64/perl5/x86_64-linux-thread-multi
>>     /usr/lib64/perl5/5.10.0
>>     /usr/lib64/perl5
>>     /usr/local/lib64/perl5
>>     /usr/local/share/perl5
>>     /usr/lib64/perl5/vendor_perl
>>     /usr/share/perl5/vendor_perl
>>     /usr/lib64/perl5
>>     /usr/share/perl5
>>     .
>> [sybase@1636541cllapp15 ~]$
>> 
>> 
>> [sybase@1636541cllapp15 ~]$ tsql -C
>> Compile-time settings (established with the "configure" script)
>>                             Version: freetds v0.91
>>              freetds.conf directory: /etc
>>      MS db-lib source compatibility: yes
>>         Sybase binary compatibility: yes
>>                       Thread safety: yes
>>                       iconv library: yes
>>                         TDS version: 4.2
>>                               iODBC: no
>>                            unixodbc: yes
>>               SSPI "trusted" logins: no
>>                            Kerberos: no
>> [sybase@1636541cllapp15 ~]$
>> 
>> 
>> $ tsql -UXXXXXX -S XXXXXX
>> Password:
>> locale is "C"
>> locale charset is "ANSI_X3.4-1968"
>> using default charset "ISO-8859-1"
>> 1>
>> 
>> #!/usr/bin/perl
>> #
>> 
>> $ENV{'FREETDSCONF'}='/opt/sybase/etc/freetds.conf';
>> print $ENV{'FREETDSCONF'};
>> 
>> 
>> use DBI;
>> 
>> my $dbh = DBI->connect("DBI:Sybase:server=XXXXXXX", "XXXXXXX", 'XXXXXXX');
>> die "unable to connect to server $DBI::errstr" unless $dbh;
>> 
>> $dbh->do("use tempdb");
>> 
>> $query = "SELECT * FROM master..sys.sysusers";
>> $sth = $dbh->prepare ($query) or die "prepare failed\n";
>> $sth->execute( ) or die "unable to execute query $query   error 
>> $DBI::errstr";
>> 
>> $rows = $sth->rows ;
>> print "$row rows returned by query\n";
>> 
>> while ( @first = $sth->fetchrow_array ) {
>> foreach $field (@first) {
>> print "field: $field\n";
>> }
>> }
>> 
>> ERROR
>> --------
>> DBI connect('server=XXXXXXX,','XXXXXXX',...) failed: OpenClient message: 
>> LAYER = (6) ORIGIN = (8) SEVERITY = (5) NUMBER = (3)
>> Server XXXXXXXXXX, database
>> Message String: ct_connect(): directory service layer: internal directory 
>> control layer error: Requested server name not found.
>>  at ./test.pl <http://test.pl/> line 10
>> unable to connect to server OpenClient message: LAYER = (6) ORIGIN = (8) 
>> SEVERITY = (5) NUMBER = (3)
>> Server wsvmvsysSQT01, database
>> Message String: ct_connect(): directory service layer: internal directory 
>> control layer error: Requested server name not found.
>> 
>> Respectfully,
>> Sumanth
> 
> 
> -- 
> Alexander Foken
> mailto:alexan...@foken.de <mailto:alexan...@foken.de>

Reply via email to