[英]bash ADB shell sqlite3 script
I am having issues getting this simple bash script to work.我在让这个简单的 bash 脚本正常工作时遇到问题。 Below is the simple script which I am trying to get to work:下面是我试图开始工作的简单脚本:
#!/bin/sh
adb shell sqlite3 /data/data/com.android.providers.tv/databases/tv.db "SELECT programs.title FROM programs"
I am getting the below error:我收到以下错误:
Error: near "SELECT": syntax error
If I run the command in terminal I get the correct output.如果我在终端中运行命令,我会得到正确的 output。 I have also tried changing SELECT to select, and it is the same issue.我也尝试将 SELECT 更改为 select,这是同样的问题。 Running manually in terminal as follows:在终端中手动运行如下:
adb shell
sqlite3 /data/data/com.android.providers.tv/databases/tv.db
sqlite> SELECT programs.title FROM programs;
*OUTPUT*
Gives the correct output.给出正确的 output。
Does anyone have any clue what I am doing wrong?有谁知道我做错了什么?
In regards to what @Jetchisel suggested, see below for what I tried with no success:关于@Jetchisel 的建议,请参阅下面的我尝试但没有成功的内容:
adb shell sqlite3 /data/data/com.android.providers.tv/databases/tv.db "SELECT programs.title FROM programs;"
adb shell sqlite3 /data/data/com.android.providers.tv/databases/tv.db "SELECT programs.title FROM programs;";
adb shell sqlite3 /data/data/com.android.providers.tv/databases/tv.db "SELECT programs.title FROM programs";
It was a simple fix, see below:这是一个简单的修复,见下文:
#!/bin/bash
adb shell sqlite3 /data/data/com.android.providers.tv/databases/tv.db '"SELECT programs.title FROM programs;"'
Needed to add single quotes around the query.需要在查询周围添加单引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.