Trying to set up ODBC on Ubuntu. osql is a great script to test it out, but running it on Ubuntu 10.10:
root:~# osql -S fcstest -U sa -P *****
osql: error: no potential directory strings in "/usr/local/bin/isql"
isql strings are:
+ /lib/ld-linux.so.2
So inspecting the code, I can extract the meaningful parts on RHEL, where it works:
ISQL=$(command -v isql)
strings ${ISQL} | grep ^/
/lib64/ld-linux-x86-64.so.2
/usr/local/lib
but on Ubuntu, the same sequence:
dchwalis:/usr/local/src$ strings ${ISQL} | grep ^/
/lib/ld-linux.so.2
Note the missing /usr/local/lib – the grep filters following will NEVER find any strings…
Maybe we should do this: RHEL:
$ ldd /usr/local/bin/isql
libodbc.so.1 => /usr/local/lib/libodbc.so.1 (0x00002b5b76eb4000)
...
and Ubuntu:
root:/usr/local/bin# ldd isql
libodbc.so.1 => /usr/local/lib/libodbc.so.1 (0x001cd000)
We can pull a path from that!
Kind of a hack: works on Ubuntu 10.10
*** /usr/local/bin/osql 2011-03-15 08:32:29.000000000 -0500
--- /usr/local/bin/osql2 2011-03-18 09:28:26.000000000 -0500
***************
*** 40,47 ****
fi
# Establish ODBC prefix directory
!
! ODBC_DIR=$(strings ${ISQL} | grep ^/ | grep -v elf | grep -v '\.so\.' | head -1 | sed 's/lib$/etc/' )
# N.B. better than head(1) would be a loop to test the strings. Since we're looking for a directory,
# something like this might work:
--- 40,46 ----
fi
# Establish ODBC prefix directory
! ODBC_DIR=$(ldd ${ISQL} | egrep 'libodbc.so.[0-9]' | sed -e 's/(0x[0-9A-Za-z]*)//g' -e 's/libodbc.so.[0-9] => //' -e 's/libodbc.so.[0-9]//' -e 's/\t *//g' -e 's|/$||' -e 's| $||' -e 's/lib\/$/etc/' )
# N.B. better than head(1) would be a loop to test the strings. Since we're looking for a directory,
# something like this might work: