Hello all,
I have a problem with a bash script. It contains an MySQL query, which when I run it 'as is', executes without a problem.
When, however, I try to get it to assign its output to a variable, using the backtick, I get errors.
So ..
.. no problem.
When, however ...
.. errors.
So I'm guessing that something in there needs to be escaped, but I can't say what.
Can someone help?
Thanks.
I have a problem with a bash script. It contains an MySQL query, which when I run it 'as is', executes without a problem.
When, however, I try to get it to assign its output to a variable, using the backtick, I get errors.
So ..
Code:
/usr/bin/mysql -N -B mydatabase -e 'SELECT COUNT(*)
FROM orders as o JOIN users as u ON o.userthing=u.package
WHERE o.table BETWEEN (now() - INTERVAL 1 day) AND
now() - INTERVAL 25 hour) AND o.p_stateorder=1 AND
u.name != "The Site" AND u.p_username NOT LIKE "myAddress@mailserver.com";'
When, however ...
Code:
result=`/usr/bin/mysql -N -B mydatabase -e 'SELECT COUNT(*)
FROM orders as o JOIN users as u ON o.userthing=u.package
WHERE o.table BETWEEN (now() - INTERVAL 1 day) AND
now() - INTERVAL 25 hour) AND o.p_stateorder=1 AND
u.name != "The Site" AND u.p_username NOT LIKE "myAddress@mailserver.com";'`
So I'm guessing that something in there needs to be escaped, but I can't say what.
Can someone help?
Thanks.