This is my script.
#!/usr/bin/sh
isql -UXx -Pxxxxxx <<!
set nocount on
use xxxx
go
select count(*) from BSC where bsc='$1'
go
!
exit
i am executing this script as :
temp2.sh 0000
the output is 0. but when i execute the query manually then the output is 1 which is correct. problem here is the command line argument $1 is not passed to the query.
how could i achieve this? I have tried all these possiblities:
bsc='$1'- output is 0
bsc="$1"- output is 0
bsc=`$1`- Syntax error
bsc="'$1'"- output is 0
I am using solaris unix and DB is sybase.
The problem here, I think, is that the single quotes in your query are being interpreted by the shell, so that
is being interpreted as
as a literal string.
I don't have anything available to me to test this with, but you might try replacing that like with
I think (and I stress again that I don't have anything available to test with right now) that the double quotes should make the single quotes print out as characters, so it will be interpreted as
given the command line input you provided.