Re: FreeTDS on Debian: connect to MSSQL with ODBC fails

"Peter C. Norton" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Thu, Dec 02, 2010 at 11:30:20AM -0500, [email protected] wrote:
> On Thu, Dec 02, 2010 at 10:26:24AM -0500, Peter C. Norton wrote:
> > On Thu, Dec 02, 2010 at 09:55:32AM -0500, [email protected] wrote:
> > > It's trickier than it might look to do correctly.  For example, isql will 
> > > not report where it looks for its odbc.ini.  So the osql script tries to 
> > > infer that by searching the binary and parsing ldd(1) output.  And then 
> > > there are the usual portability issues, such as the versions of sed(1) 
> > > and awk(1), and the options they accept.  But after 11 tries we seem to 
> > > be making some progress!
> > 
> > Quick note about the script: if you're on a platform with
> > ksh/bash/zsh, can you have autoconf/configure replace #!/bin/sh with
> > the more capable shell?  On unix variants that have a true bourne
> > shell, a lot of things don't work as expected with /bin/sh.
> 
> Ah, well, Peter, we're missing one critical resource: a more capable scripter.  
> 
> Yours truly can stumble through a Bourne shell script but I've never dealt with ksh or zsh.  I use bash interactively and try to color inside the lines such that bash invoked as /bin/sh behaves identically to any Bourne shell.  So far that's worked OK: the problems we've had with osql were never shell problems per se, but BSD/Linux utility conflicts or unexpected unixODBC arrangements.  
> 

Ah, the joys of shell scripting.  Solaris has traditionally insisted
on keeping a less-than-capable /bin/sh as the default (it was one of
the few statically linked binaries in solaris, so recovery can be done
in the miniroot.  These days, in solaris 10 there's a /bin/bash.
Other unix vendors have variations on this theme.

Most of the bash syntax and idioms that people use are actually from
ksh (~, $(), ${parameter:-word}, more complex parameter expansion like
${parameter:=word}, command-line editing, aliases, etc.) but ksh also
does a lot of things more consistently.  Some examples are that many
/bin/sh implementations don't work properly with [ -z $var ] (test is
not a built-in, so this usage fails, and then you have to rely on the
features of the platform-specific test(1)) leading to the ugly but
necessary idiom of [ "x" != "x$VAR" ] you may have seen, etc.

Anyway, currently if you code for bash, maybe you can look for bash in
configure and m4/auto* put it in the #! line explicitly so that osql
will work properly on different *nix's with less work.  

-Peter
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.