0

我编写了一个 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]

哪里出了问题?

4

1 回答 1

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

最后一件事:如果我没记错的话,你不需要最后一个分号,因为它只用于分隔几个命令而不是完成它们。

于 2013-08-23T14:37:45.850 回答