in reply to Re^3: Portable way to extract string from a binary
in thread Portable way to extract string from a binary

Well - if you've got an app that is compiled with client lib or dblib it's pretty simple to get the version - ct_config(CS_VER_STRING) for ctlib, and dbversion() in dblib, and these will return the version string from the current library (i.e. the one dynamically linked in).

Michael

  • Comment on Re^4: Portable way to extract string from a binary

Replies are listed 'Best First'.
Re^5: Portable way to extract string from a binary
by jfroebe (Parson) on Jul 14, 2004 at 15:38 UTC

    hits head to desk

    I was looking at CS_VERSION_KEY.. ugh.. need caffeine.

    So, why not just do write a small c program that just spits out the version number, capture the output? I'm thinking because if the LD_LIBRARY_PATH (or equiv) is different than ${SYBASE}/${SYBASE_OCS}/lib then it might create havoc... good thing to check if the two would match up... hmmm

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

      It's feasible, but it's a lot more work than this:
      sub getLibVersion { my $dir = shift; my $lib = "$dir/lib"; opendir(DIR, $lib) || die "Can't opendir($lib): $!"; my @files = grep(/lib(syb)?ct\./, readdir(DIR)); closedir(DIR); my $file; foreach (@files) { $file = "$lib/$_"; last if -e $file; } open(IN, $file) || die "Can't open $file: $!"; binmode(IN); my $version; while(<IN>) { if(/Sybase Client-Library\/([^\/]+)\//) { $version = $1; last; } } close(IN); if(!$version) { print "Unknown Client Library version - assuming FreeTDS.\n"; } else { print "Sybase OpenClient $version found.\n"; } return $version; }

        true... I guess I'm just hesitant on relying on a particular string with in the library... Sybase would *never ever* change that ... *cough cough wheez* ;-)

        Jason

        No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1