0

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.

MarsAtomic
  • 9,672
  • 5
  • 32
  • 55
Rahat Ali
  • 1
  • 1
  • 1

3 Answers3

1

'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'

sumitkd
  • 11
  • 3
  • hi sumitkd - thanks for your reply .. in my script i am giving command from working directory where isql exist. (cd /sybase/OCS-15_0/bin/).. is even it required to set the environment variables – Rahat Ali Jul 28 '16 at 05:38
  • Yes. It is required. I am not very sure how that works but, from my experience I believe `isql` too needs some of those environment variables to work properly. – sumitkd Jul 28 '16 at 06:25
  • hi sumitkd - thanks for your reply - after giving environment variables in batch script , now its not giving any error.. but still cant execute the query..... my output is as ...... --- query ----- -- environment variable done --- 1> – Rahat Ali Jul 28 '16 at 07:39
  • I have updated my original answer to include a suggestion for this. – sumitkd Jul 29 '16 at 09:48
1

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.

Ken Sharp
  • 789
  • 8
  • 21
0

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)