Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Command line 使用时检查结果<;sqlite3_Command Line_Sqlite - Fatal编程技术网

Command line 使用时检查结果<;sqlite3

Command line 使用时检查结果<;sqlite3,command-line,sqlite,Command Line,Sqlite,我需要知道这个命令在script.sh文件中是成功还是失败 sqlite3 database.db < database.sql sqlite3 database.db

我需要知道这个命令在script.sh文件中是成功还是失败

sqlite3 database.db < database.sql
sqlite3 database.db
我的想法是:

$result = ('sqlite3 database.db < database.sql')
$result=('sqlite3 database.db

如果$result包含某些内容,我将保释。否则,如果结果不包含任何内容,我将继续。

sqlite3
工具将返回正常错误状态,您可以使用正常的shell方法进行检查(
if
$?
等):

$if sqlite3 test.db“select 42;”;然后呼应成功;else回波失效;fi
42
成功
$if sqlite3 test.db“select x;”;然后呼应成功;else回波失效;fi
错误:没有这样的列:x
失败

下面是现在发生的事情。。。我在我的脚本中运行了这个:sqlite3 database.db