The problem with escaping in bash using isql

I'm currently working on a small backup of a script from some firebird databases, and I am having a weird escaping problem that I seem to be unable to solve. Here the thing in my script is creating the sqlog variable into which I would like to put the output of the command chain, 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 a 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.

An unknown RDB table means my attempt to escape $.

thanks for any help :)

+3
source share
2 answers

try

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

Line:

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

install sql in

SELECT * FROM RDB$DATABASE;

, , , isql $DATABASE.

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

isql? ...

0

Source: https://habr.com/ru/post/1748113/


All Articles