Sybase connection failing through shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sybase connection failing through shell script
# 1  
Old 12-21-2012
Sybase connection failing through shell script

Hi All,

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.

Code:
#!/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

Code:
error:
ct_init(): network packet layer: internal net library error: Attempt to load protocol driver failed
Attempting to obtain a localized error message failed.

# 2  
Old 12-21-2012
Add your Sybase library directories to LD_LIBRARY_PATH environment variable.
Code:
export LD_LIBRARY_PATH="/usr/sybase/lib/:$LD_LIBRARY_PATH"

Replace highlighted section with relevant directories. I hope this helps.

---------- Post updated at 11:26 ---------- Previous update was at 11:21 ----------

For further reference: Sybase Environment Variables

This page also suggest to source SYBASE.csh or SYBASE.sh in your script to set environment variables.
# 3  
Old 12-21-2012
HI mate,

i tried the above solution, still get the same error.

Code:
#!/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 :
Code:
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.

# 4  
Old 12-21-2012
Now that is a different error message.

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.

Reference: Login failure to Adaptive Server
# 5  
Old 12-21-2012
hey ,

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.

cheers
# 6  
Old 12-21-2012
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.

Last edited by Scott; 12-21-2012 at 02:21 PM.. Reason: Added "edit"
# 7  
Old 12-21-2012
Yes, I totally agree with Scott. I do not see any syntax error in your code. It should work!

BTW I see you have added $SYBASE_ASE to LD_LIBRARY_PATH

Can you also add $SYBASE_OCS & $SYBASE_FTS suggested by the manual. Also compare the env as suggested by Scott.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract top 20 records from sybase db in shell script

Hi, I am new to advanced scripting. I need to get top 20 records from database (Sybase) with a condition that all Char/varchar columns should have more than 4 characters. I need to do this via shell scripting, I have got half logic (on how to get varchar/char columns and stored it in a... (2 Replies)
Discussion started by: Selva_2507
2 Replies

2. Solaris

network connection failing

hi, I'm setting up a home lab and I am having problems keeping my connection open on putty. every time i leave it for about 10 seconds and come back I keep having to re-connect. I'm more of a AIX person and trying to get more fimilar with Sun but some of the commands I am trying to run to diag... (2 Replies)
Discussion started by: vpundit
2 Replies

3. Solaris

Sybase Connectivity Check through Shell Script

Hi, I need to check the sysbase database connectivity through the Unix Shell Script. Can you help me on the how to write the script to test the sysbase database connection. Thanks in Advance Nandha (0 Replies)
Discussion started by: nandha2387
0 Replies

4. Shell Programming and Scripting

Capturing Sybase SP output in Shell Script

Greetings, I need to capture the output of a Sybase stored procedure, inside my shell script( k shell). Based on this output, I need to call another perl script, with input arguments as the result set of the procedure execution. I need to keep looping through and call the perl script, ... (2 Replies)
Discussion started by: rajpreetsidhu
2 Replies

5. Shell Programming and Scripting

Sybase Connection Issue

I am trying this >$ /usr/sybase/bin/isql -UABC -Pdef -SXYZ -b Getting the following error. Help is appreciated (1 Reply)
Discussion started by: pinnacle
1 Replies

6. UNIX for Dummies Questions & Answers

sybase connection through shell-script

:mad: how do i connect to sybase through shell script written in linux (9 Replies)
Discussion started by: Amitabh
9 Replies

7. UNIX for Dummies Questions & Answers

How to authenticate sybase login thru shell script ?

Hi All, This is my first post. Need your favour guys. I need to authenticate syabse login/password thru shell script. I am getting the ID & Pwd form user and storing it in variable.. But how to authenticate and echo user back if the id/pwd doesnt work. isql -U$1 -P$2 -S$3 ?? thanks in... (3 Replies)
Discussion started by: libin4u2000
3 Replies

8. Shell Programming and Scripting

Connecting to sybase via shell script.

Hi All, I was able to connect to sybase in shell script and also able to run few sql queries, something like this, #!/usr/bin/ksh -x temp=`echo "select name from sysobjects where type = 'U'"` results=`isql -SDS_SERVER-UAdhocUser -Pha12 <<EOF set rowcount 6 $temp go EOF` line_count=0... (1 Reply)
Discussion started by: arvindcgi
1 Replies

9. Shell Programming and Scripting

Connect to sybase database using Korn shell script

Hi, Can anyone please give me a script or let me know how to connect to a sybase database and execute a query using Korn shell scripts.Am new to Unix but i need to do this ASAP. Please help. Thanks, Gops (7 Replies)
Discussion started by: bhgopi
7 Replies

10. Shell Programming and Scripting

remote sybase connection and php error.

Hi all, I am trying to connect to a remote sybase database server (sitting on windows) from my freebsd apache webserver. My Webserver has installed; Apache2.0 PHP 4.3.8 Freetds with ODBC enables ( tsql works but isql doesnt ) unixODBC syabse-ocsd When i connect with tsql from... (4 Replies)
Discussion started by: lealyz
4 Replies
Login or Register to Ask a Question