1
我在我的bash脚本中运行sql时遇到了一些问题。有人可以建议什么语法需要改变?在sql字符串中使用bash参数的脚本问题
{
echo "listing"
sshpass -p 'XXXXXX' ssh [email protected] 'mysql -h host -u user -pXXXXXX database -e "select user_id from users where concat(FIRST,LAST) like '%${username}%';"'
} > $log
以下是错误消息我收到:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%jaylefler%' at line 1
当我更改了脚本推荐下面我收到以下错误:
bash: -c: line 0: syntax error near unexpected token `('
bash: -c: line 0: `mysql -h host-u user -pxxxxxxx database -e select user_id from users where concat(FIRST,LAST) like '%name_here%';'
我原来的“工作段'如下:
echo "environment"
sshpass -p $ldappw ssh [email protected] 'mysql -h host -u user -ppassword database -e "select concat(FIRST,LAST) from users;"' | (grep -i ${username} || echo "NO USER IDENTIFIED")
我只是想修改这个,所以我可以打印出找到的用户标识,而不是每次找到姓和名时都打印出的用户名。
这是行不通的。 – user3299633
“不起作用”比用作错误描述更糟糕。会发生什么? –
更新原始帖子,遇到错误。 – user3299633