简体   繁体   中英

bash ADB shell sqlite3 script

I am having issues getting this simple bash script to work. 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. I have also tried changing SELECT to select, and it is the same issue. 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.

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM