Rahat Ali
Rahat Ali

Reputation: 1

Isql command error while executing query on Sybase database

I would like to create a Windows batch file to execute the query on Sybase database running on Linux.

Batch file:

plink.exe -ssh sybase@<IP> -pw <PW> -m C:\scripts\script1.bat -t > C:\scripts\testing.log

script1.bat:

echo --- query 1 -----
cd /sybase/OCS-15_0/bin/
isql -Uimaldb_bkp -Pstart_bkp -SLinux1 -Dimaldb
sp_helpsegment
go
exit

It works fine until isql command and gives output in testing.log:

--- query 1 ----- bash: isql: command not found bash: sp_helpsegment: command not found bash: go: command not found

Please advice.

Upvotes: 0

Views: 9416

Answers (3)

Juan Pe&#241;aherrera
Juan Pe&#241;aherrera

Reputation: 55

If you don't have permission to change de server PATH, you can find the path of isql and execute this way:

/sybase/OCS-15_0/bin/isql -Uimaldb_bkp -Pstart_bkp -SLinux1 -Dimaldb

Putting the prefix PATH of isql installation (it depends of your version and path)

Upvotes: 0

user12985934
user12985934

Reputation: 11

I too face the same issue. You need to insert your sybase environment variables, like below:

. /sybase/ABD/SYBASE.sh
isql -U**** -P****** -S<SID> -X <<EOF

It will work fine. Please try this.

Upvotes: 1

sumitkd
sumitkd

Reputation: 11

'isql' will work once the required environment variables for Sybase ASE are set in the database server (Linux server as mentioned by you). Please check the link below for more details:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc35823.1570/html/uconfig/X30690.htm

On a simpler note, there should be a file named 'SYBASE.sh' inside '/sybase' (I guess Sybase has been installed in this directory from your sample code). You need to source this file by editing the '.bashrc' file present inside the home directory of the user you are using to connect to the Linux server.

For the sql to work, you will need a flag to indicate the start and end of sql block in the script. Please try the following:

isql -Uimaldb_bkp -Pstart_bkp -SLinux1 -Dimaldb <<EOF
sp_helpsegment
go
EOF

You can use any other word instead of 'EOF'

Upvotes: 1

Related Questions