Bash 脚本 SQLITE - 选项太多
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19352108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bash Script SQLITE - Too Many Options
提问by crankshaft
Can't figure this one out, if I execute the command directly in the shell, then it executes successfully, but running from a script file I get the following error:
想不通,如果我直接在shell中执行命令,那么它执行成功,但是从脚本文件运行我得到以下错误:
sqlite3: Error: too many options: "INTO"
sqlite3:错误:选项太多:“INTO”
#!/bin/bash
sql="\"INSERT INTO keys ('date','chan','key','name','desc','ser','ep','cat') VALUES('xxx','xxx','xxxx','xxxx','xxxxx.','xxx','xxx','xxxx');\""
echo $sql
sqlite3 mydb.db $sql
Any ideas on what the problem might be ?
关于问题可能是什么的任何想法?
采纳答案by higuaro
Double quote the $sql
variable in the script:
双引号$sql
脚本中的变量:
#!/bin/bash
sql="\"INSERT INTO keys ('date','chan','key','name','desc','ser','ep','cat') VALUES('xxx','xxx','xxxx','xxxx','xxxxx.','xxx','xxx','xxxx');\""
echo $sql
sqlite3 mydb.db "$sql"
回答by Drey
In my case the problem was in the binary I execute:
就我而言,问题出在我执行的二进制文件中:
cat /opt/sbin/sqlite3:
#!/bin/sh
export LD_LIBRARY_PATH="/opt/lib:$LD_LIBRARY_PATH"
/opt/sbin/sqlite3.real $@
So if I execute /opt/sbin/sqlite3.real I have no problems.
所以如果我执行 /opt/sbin/sqlite3.real 我没有问题。