我编写了一个shell脚本来执行我的数据库查询
mysql -uroot -pshruti2 -B -e "use WebNmsDB;select HEADERINDEX from tekelec_meas_headers where CLLI=$clli and IVALSTART>="$ivalstart" and IVALSTART<"$ivalend" and RPTTYPE="$rpttype";" > win.txt
但是win.txt中的输出是
/mysql Ver 14.12 Distrib 5.0.44, for unknown-linux-gnu (x86_64) using EditLine wrapper
Copyright (C) 2002 MySQL AB
This is commercial software, and use of this software is governed
by your applicable license agreement with MySQL
Usage: /Tekelec/WebNMS/mysql/bin/mysql [OPTIONS] [database]
哪里出错?
答案 0 :(得分:0)
使用'$var'
代替"$var"
。您应该只使用双引号来打开和关闭MYSQL命令。
该命令现在看起来像这样:
mysql -uroot -pshruti2 -B -e "use WebNmsDB;select HEADERINDEX from tekelec_meas_headers where CLLI=$clli and IVALSTART>='$ivalstart' and IVALSTART<'$ivalend' and RPTTYPE='$rpttype'" > win.txt
最后一件事:如果我没有弄错,你不需要最后一个分号,因为它只用于分隔几个命令而不是完成它们。