场景: 我正在尝试一个小的shell脚本程序。在
在这个程序中-我试图查询一个有两个表的数据库。试图得到一个是或不是的答案。在
我使用python脚本从文件中获取的etag = md5sum
。在
echo 'select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and b.hashuser='$etag''
当我试图在屏幕上打印它时,它清楚地显示了etag作为md5sum
但是,如果我试图在数据库中查询它并尝试获取结果。使用下面给出的脚本
^{pr2}$这是我得到的错误。在
Error: unrecognized token: "579f0b61cf958a0eea2f60906e6a04a4"
在google上搜索了一下之后,这就是我从这个link找到的解决方案
然后我把它改成${#etag}
echo 'select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and b.hashuser='${#etag}''
我现在得到的错误是
select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and **b.hashuser=32**
为什么b.hashuser=32。是我的第一个问题。在
第二个问题:
当我试图使用上述函数查询数据库时:
sqlite3 hashez.db 'select a.hash,b.hashuser, case when a.hash=b.hashuser then "No!" else "yes!" end from tempo b, hashes a where a.hash=b.hashuser and b.hashuser='${#etag}''
我没有得到回复。在
对不起,我的英语不好
你在胡说你的报价。在
注意单引号内的双引号,以及参数替换周围的双引号。在
相关问题 更多 >
编程相关推荐