Search code examples
shellsybaseisql

Print sql output messages to a file in shell script


I need to run SQL scripts and wanted to capture that output to a log file. I am trying to access Sybase using ISQL and below is the sample file, though only echo messages are getting printed in the log file.

Command that I am running on windows box is this:

./Test.sh > $JOBSROOT/Test/Scripts/logtest/test.log 2>&1

#!/bin/sh
#ident "%W%" 
#
echo "Trying to print"

ISQL_EOD="$ISQL -S $DB_SERVER -U $DB_DRMSUSER -P $DB_DRMSPASS -w999"

cd ${JOBSROOT}/Test/Scripts/logtest/
echo "Echo Prints"

$ISQL_EOD  << ADDE
set nocount on

select 'A HouseKeeper job'

set nocount off
ADDE

First time I am doing this hence could be wrong anywhere in this, please help me to understand it and find out the faulty line.


Solution

  • Seems like your command is missing a go In isql, commands are executed by issuing go on it's own line.

    set nocount on
    
    select 'EMEA VPE VOT Morning HouseKeeper job'
    
    set nocount off
    
    go