Re: Problems Connecting Debian --> MSSQL through odbc

Jaap van Arragon <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <C6832C18.22AB9%[email protected]>
I've used the NEW version of your script!

Ldd shows:

SERVER:~# ldd $(command -v isql)
    linux-gate.so.1 =>  (0xffffe000)
    libodbc.so.1 => /usr/lib/libodbc.so.1 (0xb7e8e000)
    libodbcinst.so.1 => /usr/lib/libodbcinst.so.1 (0xb7e83000)
    libreadline.so.5 => /lib/libreadline.so.5 (0xb7e52000)
    libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb7e39000)
    libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7cde000)
    libltdl.so.3 => /usr/lib/libltdl.so.3 (0xb7cd7000)
    libncurses.so.5 => /lib/libncurses.so.5 (0xb7ca5000)
    /lib/ld-linux.so.2 (0xb7ef6000)
    libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7ca0000)

###################################################

SH -X shows:

SERVER:~# sh -x ./osqlscript.sh -S TEST -U admin -P pass
++ basename ./osqlscript.sh
+ USAGE='Syntax: osqlscript.sh -S server -U user -P password'
+ getopts I:S:U:P: OPTION
+ case ${OPTION} in
+ DSN=TEST
+ getopts I:S:U:P: OPTION
+ case ${OPTION} in
+ USERNAME=admin
+ getopts I:S:U:P: OPTION
+ case ${OPTION} in
+ PASSWORD=pass
+ getopts I:S:U:P: OPTION
+ '[' -z TEST -o -z admin -o -z pass ']'
++ command -v isql
+ ISQL=/usr/bin/isql
+ '[' -z /usr/bin/isql ']'
++ strings /usr/bin/isql
++ grep '^/'
++ grep -v elf
++ grep -v '\.so\.'
++ head -1
++ sed 's/lib$/etc/'
+ ISQL_DIR=
++ basename ./osqlscript.sh
+ INI_DIRNAME=/tmp/osqlscript.sh.15501
+ exec
+ '[' -z '' ']'
+ echo 'checking shared odbc libraries linked to isql for default
directories...'
checking shared odbc libraries linked to isql for default directories...
+ echo
+ ldd /usr/bin/isql
+ awk '/[-]lodbc/ {print $3}'
+ read L
+ strings ''
strings: '': No such file
+ grep '^/'
+ grep -v /lib
+ read D
+ read L
++ cat /tmp/osqlscript.sh.15501
+ ODBC_DIR=
+ rm /tmp/osqlscript.sh.15501
+ '[' -z '' -a -z '' ']'
++ basename ./osqlscript.sh
++ command -v isql
+ echo 'osqlscript.sh: problem: no potential directory strings in
"/usr/bin/isql"'
osqlscript.sh: problem: no potential directory strings in "/usr/bin/isql"
++ basename ./osqlscript.sh
+ echo 'osqlscript.sh: advice: use "osql -I DIR" where DIR unixODBC\'\''s
install prefix e.g. /usr/local'
osqlscript.sh: advice: use "osql -I DIR" where DIR unixODBC\'s install
prefix e.g. /usr/local
+ echo 'isql strings are:'
isql strings are:
+ strings /usr/bin/isql
+ grep '^/'
+ sed 's/^/+ /'
+ /lib/ld-linux.so.2
+ '[' '' ']'
+ echo 'checking odbc.ini files'
checking odbc.ini files
+ for F in '"${HOME}/.odbc.ini"' '"${ODBC_DIR}/odbc.ini"'
++ dirname /root/.odbc.ini
+ '[' '!' -d /root ']'
+ '[' -r /root/.odbc.ini ']'
+ echo '    reading' '"/root/.odbc.ini"'
    reading "/root/.odbc.ini"
+ grep '[TEST]' /root/.odbc.ini
+ '[' 0 -eq 0 ']'
+ echo '[TEST]' found in '"/root/.odbc.ini"'
[TEST] found in "/root/.odbc.ini"
+ ODBC_INI=/root/.odbc.ini
+ break
+ '[' -z /root/.odbc.ini ']'
+ echo found this section:
found this section:
+ SED_CMD='/^\[TEST\]/,/^[[:space:]]*$/ { s/^/    /; p; }'
+ sed -ne '/^\[TEST\]/,/^[[:space:]]*$/ { s/^/    /; p; }' /root/.odbc.ini
    [TEST]
    Driver          = FreeTDS
    Description             = A good description of your DB
    Trace           = Yes
    Server          = [10.10.10.51]
    Port            = 1433
    TDS_Version     = 7.0
    
+ for D in '"${DSN}"' ''\''default'\'''
+ echo 'looking for driver for DSN [TEST]'
looking for driver for DSN [TEST]
+ grep TEST /root/.odbc.ini
+ '[' 0 -eq 0 ']'
+ CMD='/^\[TEST\]/,/^[[:space:]]*$/ { s/^/    /; p; }'
++ sed -ne '/^\[TEST\]/,/^[[:space:]]*$/ { s/^/    /; p; }' /root/.odbc.ini
++ grep -Ei '^[[:space:]]*driver[[:space:]]*='
+ DRIVER_LINE='    Driver          = FreeTDS'
+ '[' -z '    Driver          = FreeTDS' ']'
++ echo Driver = FreeTDS
++ awk -F '[[:space:]]*=[[:space:]]*' '{print $2}'
+ DRIVER=
+ '[' '' ']'
++ basename /root/.odbc.ini
+ echo 'driver line incomplete for [TEST] in .odbc.ini'
driver line incomplete for [TEST] in .odbc.ini
+ continue
+ for D in '"${DSN}"' ''\''default'\'''
+ echo 'looking for driver for DSN [default]'
looking for driver for DSN [default]
+ grep default /root/.odbc.ini
+ '[' 1 -eq 0 ']'
+ '[' -z '' ']'
++ basename ./osqlscript.sh
++ basename /root/.odbc.ini
+ echo 'osqlscript.sh: error: no driver found for [TEST] in .odbc.ini'
osqlscript.sh: error: no driver found for [TEST] in .odbc.ini
+ exit 1

###################################################
echo     Driver          = FreeTDS \
> | awk -F '[[:space:]]*=[[:space:]]*' '{print $2}'

Prints Nothing!
###################################################

ODBCINST.ini is in my /et/odbcinst.ini

ODBCINST.ini:

[TEST]
Description             = FreeTDS 0.82-4, unixodbc 2.2.11-16
Driver          = /usr/lib/odbc/libtdsodbc.so
TraceFile               = /tmp/sql.log
Trace           = Yes
UsageCount              = 1



LIBTDSODBC.so is located in:   /usr/lib/odbc/libtdsodbc.so




On 7/14/09 10:43 PM, "[email protected]" <[email protected]>
wrote:

> On Tue, Jul 14, 2009 at 09:50:48PM +0200, Jaap van Arragon wrote:
>> I've runned the script and here is the output:
>> 
>> SERVER:~# ./osqlscript.sh -S TEST -U admin -P pass
>> checking shared odbc libraries linked to isql for default directories...
>> strings: '': No such file
> 
> What is the output of "ldd $(command -v isql)"?
> 
> I would be interested to see the output of
> 
> $ sh -x ./osqlscript.sh -S TEST -U admin -P pass
> 
>> osqlscript.sh: problem: no potential directory strings in "/usr/bin/isql"
>> osqlscript.sh: advice: use "osql -I DIR" where DIR unixODBC\'s install
>> prefix e.g. /usr/local
>> isql strings are:
>> + /lib/ld-linux.so.2
> 
> The above interrogation -- which tries to discover where unixODBC is installed
> -- failed.  osql could stop here, but proceeds with examining the per-user
> files.  
> 
>> checking odbc.ini files
>>     reading "/root/.odbc.ini"
>> [TEST] found in "/root/.odbc.ini"
> 
> You're apparently running as root, so, yes, it finds root's per-user file.
> 
>> found this section:
>>     [TEST]
>>     Driver          = FreeTDS
>>     Description             = A good description of your DB
>>     Trace           = Yes
>>     Server          = [10.10.10.51]
>>     Port            = 1433
>>     TDS_Version     = 7.0
>>     
>> looking for driver for DSN [TEST]
>> driver line incomplete for [TEST] in .odbc.ini
> 
> Apparently the grep/sed/awk combination failed to parse
> 
> Driver          = FreeTDS
> 
> What does this print:
> 
> $ echo  Driver          = FreeTDS \
> | awk -F '[[:space:]]*=[[:space:]]*' '{print $2}'
> 
> Maybe your awk doesn't recognize "[[:space:]]" as a regular expression?  (I
> doubt that's the case; it works on RHEL.)  Anyway, the "sh -x" command above
> should shed some light on these questions.
> 
> Meanwhile, you're helping me debug the debugger, and getting no closer to your
> own solution.  So let me explain what you need to look for while you're
> helping me. 
> 
> The Driver line in your odbc.ini can refer to one of two things:
> 
> 1.  A shared object e.g. /lib/libtdsodbc.so, or
> 2.  An entry in odbcinst.ini
> 
> The latter gives you one move level of indirection.  If you want to use it,
> you should have an odbcinst.ini that looks like this:
> 
> [FreeTDS]
> Description = FreeTDS ODBC driver version 0.82
> Driver = /path/to/your/libtdsodbc.so
> 
> Where is your odbcinst.ini, and what does it say?  And where is libtdsodbc.so?
> 
> HTH.  
> 
> --jkl
> 
> 
> _______________________________________________
> FreeTDS mailing list
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.