Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping Problem in bash using isql

Tags:

bash

isql

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 :)

like image 505
flazzarini Avatar asked Oct 24 '25 17:10

flazzarini


1 Answers

try with

sqllog=`echo 'SELECT * FROM RDB\$DATABASE;' | isql -u SYSDBA -pass mypasswd localhost:mydatabase | tail -n 2 | head -n 1 | wc -l`
like image 138
mathk Avatar answered Oct 26 '25 08:10

mathk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!