I'm trying to connect to Sybase via shell script. i'm getting the following error.
Please let me know where i'm going wrong. Note that i'm not having this issue when connecting via terminal.
#!/usr/bin/bash
SYBASE=/usr/sybase
ISQL=$SYBASE/bin/isql
export SYBASE ISQL
$ISQL -Uuser -Ppwd -Sfoo <<EOF
use db
go
select count(*) from some_table
go
EOF
error:
ct_init(): network packet layer: internal net library error: Attempt to load protocol driver failed
Attempting to obtain a localized error message failed.
i tried the above solution, still get the same error.
#!/usr/bin/bash
LD_LIBRARY_PATH="/usr/sybase/ASE-12_5/lib:$LD_LIBRARY_PATH"
SYBASE="/usr/sybase:$SYBASE"
/path/to/dir/isql -Uuser -Ppwd -SFOO <<EOF
use db
go
select count(something) from some_table
go
EOF
error :
Msg 4002, Level 14, State 1:
Server 'FOO':
Login failed.
CT-LIBRARY error:
ct_connect(): protocol specific layer: external error: The attempt to connect to the server failed.
As per Sybase, this message is a generic login failure message that does not tell the connecting user whether the failure resulted from a bad user name or a bad password. This generic message guards against malicious attempts to gain access to Adaptive Server.
thanks for the quick reply. I connected to the Database with the same credentials from the terminal and it works. for some reason it fails when i call it from within the shell script.
I'm sure it's not magic! If it works in one place and not the other, this strongly suggests that you environment is not the same in both places. Compare the environment from your "terminal" to the one your script sees, using env.
edit: and don't forget to export the appropriate environment variables.