4

I am currently working on a little backup script from some firebird databases and I've come up with a weird escaping problem that I don't seem to be able to solve. Here's the thing in my script I create a variable called sqllog in which I would like to put the output of a chain of commands, here it is.

sqllog=`echo "SELECT * FROM RDB\$DATABASE;" | isql -u SYSDBA -pass mypasswd localhost:mydatabase | tail -n 2 | head -n 1 | wc -l`

if I try to execute this in shell I get the following error

Statement failed, SQLCODE = -204

Dynamic SQL Error
-SQL error code = -204
-Table unknown
-RDB
-At line 1, column 15.

Table unknown RDB means it didn't take my try to escape the $.

thx for any help :)

1
  • in fact the `` signs are arround the statement
    – flazzarini
    Jun 2, 2010 at 8:30

2 Answers 2

4

try with

sqllog=`echo 'SELECT * FROM RDB\$DATABASE;' | isql -u SYSDBA -pass mypasswd localhost:mydatabase | tail -n 2 | head -n 1 | wc -l`
1
  • awesome that work I just replaced the " quotes with ' quotes :) thx for everyone helping me :)
    – flazzarini
    Jun 2, 2010 at 9:20
0

The line :

sql=$(echo "SELECT * FROM RDB\$DATABASE;")

will set sql to

SELECT * FROM RDB$DATABASE;

I suppose that it is what you want i.e. that the isql command will interpret the $DATABASE variable.

(If not and DATABASE is a shell variable, then you just have to use sql=$(echo "SELECT * FROM RDB$DATABASE;")

What did isql expect ? Give me more details ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.