我在npm install sqlite3 --build-from-source = sqlite3上安装了SQLite,运行起来没有任何问题。但是,当尝试使用sqlite3通过命令行运行SQLite时,找不到此命令。错误:-bash: sqlite3: command not found
当我运行下面示例中的脚本时,它工作正常。
是否缺少要识别的sqlite3命令的路径配置?毕竟,sqlite已经安装并正在运行。
脚本测试正常:
#!/usr/bin/env node
var sqlite3 = require('sqlite3').verbose();
var db
我希望运行一个bash脚本,该脚本要求在sqlite查询中使用一个变量。
我没有编写脚本的实际经验,无论如何,我尝试过以下类似的方法,但是它不起作用。甚至没有给出一个错误,只是它没有显示任何东西。
#!/bin/bash
echo name
read name
sqlite3 /arch.db << 'EOF'
.headers on
select type, number, address from documents where name = '$name';
EOF
我很感谢你的帮助。
我正在尝试在bash脚本中同时运行Python和bash命令。在bash脚本中,我想执行一些包含在Python循环中的bash命令:
#!/bin/bash
python << END
for i in range(1000):
#execute some bash command such as echoing i
END
我该怎么做呢?
我不想手动运行这些命令。如何在bash脚本中实现自动化?
sqlite3 /var/lib/pve-cluster/config.db
sqlite> select * from tree where name = 'corosync.conf';
sqlite> delete from tree where name = 'corosync.conf';
sqlite> select * from tree where name = 'corosync.conf';
sqlite> .quit
我现在有一个可以归结为以下内容的脚本:
#!/bin/bash
SEARCH_PARAM="$1"
SQLITE3_DB="$2"
# Don't inject me please :(
sqlite3 "$SQLITE3_DB" "SELECT foo FROM Bar WHERE bundleId='$SEARCH_PARAM';"
一个明显的问题是SQL值非常容易受到$SEARCH_PARAM注入的攻击。我可以通过bash脚本修复这个问题吗?或者我需要使用另一种脚本语言,比如Python,才能访问
我使用下面的脚本从数据库文件中获取其中一个变量的数据
#!/bin/bash
sqlite3 pdu.db <<'END_SQL'
.timeout 2000
SELECT Variable_Value FROM Data Where Sr_No'7';
END_SQL
现在,我希望将上述命令的输出存储在一个变量中。如何将多个命令输出存储在shell脚本中的一个变量中?
我的Bash脚本使用SQLite存储数据。我正在比较id(列jid)与表tester ( id's在表test2中)的比较
sqlite3 jail.db "SELECT jid FROM tester" | while read jid; do
if sqlite3 jail.db "select exists(select 1 from test2 where jid=$jid limit 1)"; then
echo "i found it"
else
echo "i did not find it&
我在下面编写了一个小小的bash脚本,它按预期工作,但是我为可读性添加了一些注释和换行符,这破坏了代码。删除注释和换行符将使其成为一个有效的脚本。
### read all measurements from the database and list each value only once
sqlite3 -init /tmp/timeout /tmp/testje.sqlite \
'select distinct measurement from errors order by measurement;' |
### remove the first line o
我希望将数据库表中的特定列值与shell脚本中各自的输入字符串进行比较。我该怎么做?在下面的脚本中,我想读取所有的客户值,但它只读取第一个值。我能做什么?
customer=$(sqlite3 $databasename.db "select cus_name from $table_name"); if [[ $c_name != $customer ]];
#!/bin/bash
echo " --- Enter the Database name ---"
read databasename
echo " --- enter the
谢谢你抽出时间来看这个。我最近开始用Bash编写脚本,并希望编写一个小脚本,根据所选参数的不同,用户输入将在sqlite数据库中编写。我完全被卡住了,如果你有时间和想法,如果你能回答这个问题,我会非常高兴的。我的代码现在看起来像是这样的:
#!/bin/bash
### checking if database is availibe etc.
## ...
if [ $# -gt 0 ]
case $1 in
"--add")
case $2 in
"-t")
sql
我想运行我的自定义脚本,但是每次我需要执行它时,我都必须在脚本名之前输入bash。但是,我想运行它,就像我们运行其他脚本一样,比如ls git sed chmod等,在这些脚本名称之前不需要输入bash。
我在这里没有找到任何解决方案,但最接近的是这个巴什脚本什么都不做
我创建了一个名为test的脚本
#!/bin/bash
echo Hello
但是,当我在终端上键入它时,它不会出错,也不会打印任何内容。
user@notebook:~$ test
user@notebook:~$
但是当我用bash键入它时,它会工作。
user@notebook:~$ bash test
Hello
u
如何在下面的shell脚本中定义提交?
#!/bin/bash
echo " --- Enter the Database name ---"
read databasename
echo " --- enter the table name --- "
read table_name
sqlite3 $databasename.db "DROP TABLE IF EXISTS $table_name;"
sqlite3 $databasename.db "CREATE TABLE IF NOT EXISTS $table_
目前,我正在从sqlite数据库中删除手动老数据(旧数据超过90天),因此下面是当前执行的步骤。伙计们,这能用Bash脚本来完成吗??
1. cd /opt/db (my database location)
2. ls -lSh | head -n30 (sorting from top highest size .db files and notes all .db names)
3. sqlite3 test1.db (select database)
4. delete from tbl_outbox wh