我已经编写了一个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]哪里出了问题?
发布于 2013-08-23 22:37:46
使用'$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最后一件事:如果我没记错的话,你不需要最后一个分号,因为它只用来分隔几个命令,而不是用来结束它们。
https://stackoverflow.com/questions/18398898
复制相似问题