![]() |
#1 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
invoking sql in a shell script
Hi all,
I would like to invoke sql to update a table in KoboReader.sqlite on my Kobo. But, if I am able to write the sql update, tested on a copy of the KoboReader.sqlite on my PC (Windows 8) with the SQLite Manager for firefox, I don't know the way to access this database in shell. My purpose is to call the shell by a user command in the KoboTweaks plugin. Can someone guide me to solve my problem ? Thanks. |
![]() |
![]() |
![]() |
#2 |
Member
![]() ![]() ![]() Posts: 11
Karma: 204
Join Date: May 2013
Device: Kobo Glo
|
There is a command-line sqlite tool called sqlite3. First, you will need to install it to your Kobo. I haven't tested, but I would assume that you can install the one from Debian (following https://www.mobileread.com/forums/sho...12&postcount=2) along with all the packages it depends on.
Once installed, you can run sqlite3 on the KoboReader.sqlite database, passing the query(ies) that you want to run as standard input and getting the result as standard output. Here is an example: Code:
echo 'select * from user;' | sqlite3 /mnt/onboard/.kobo/KoboReader.sqlite |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 77
Karma: 206176
Join Date: Apr 2013
Location: Europe
Device: Kobo Glo
|
The japanese CFW includes a compiled sqlite3 and scripts as examples:
https://www.mobileread.com/forums/sho...d.php?t=213116 look in the KoboRoot.tgz in the .kobo folder in Kobo_CFW_Ver0.95.zip |
![]() |
![]() |
![]() |
#4 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
Thanks fo your answers.
I thought that was only a syntax question, didn't think I would have to install anything. Is there a language (C or else) in wich I can programm my sql update and call it in my shell, without installing anything ? I suppose there's a solution, parts of the firmware acceed to this database, so all is here to do it. (maybe I'm wrong) |
![]() |
![]() |
![]() |
#5 |
Pain in the arse
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
I think it's more simple to install the tool... see the link posted by yoq, you have only to copy that file.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
Thanks Lucas and yoq.
From the KoboRoot.tgz got on the yoq's link, I removed everything in, except : /bin/sqlite3 /usr/lib/libsqlite3.so.0 /usr/lib/libsqlite3.so.0.8.6 Do you confirm it's the only necessary files needed to invoke sql in shell ? |
![]() |
![]() |
![]() |
#7 |
Pain in the arse
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
I don't know, I've not ever used it. Just try
![]() |
![]() |
![]() |
![]() |
#8 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
After tests, I have to keep 4 other files :
/usr/lib/libncurses.so.5 2 /usr/lib/libncurses.so.5.7 /usr/lib/libreadline.so.6 /usr/lib/libreadline.so.6.1 I have another question : Let's suppose my shell is /mnt/onboard/.kobo/MyShell.sh How do I have to build my KoboRoot.tgz to make this shell automatically called after upgrade with the plugin ? |
![]() |
![]() |
![]() |
#9 |
Pain in the arse
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
I have not understood well... with "shell" do you mean script? Do you want to automatically invoke a script at startup, and reinstall it easily after every firmware upgrade?
If so, to run the script at startup you have only to add it to the rcS file. About reinstalling the hack, take a look to the source code of the Night Mode hack: yoq had implemented a simple way to do it. I suggest you to _not_ put under /mnt/onboard the script and any other file your hack will use, since they could corrupt your database (see Night Mode thread). Last edited by Lucas Malor; 05-29-2013 at 05:11 PM. |
![]() |
![]() |
![]() |
#10 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
Excuse me for my bad English, I'm French.
What I want to do, is to run my script one time, just after the plugin has been installed. If the solution is to force startup, I've understand your explanation. If there's a solution to make it run without restart the Kobo, I don't know how. Last edited by Mingyar; 05-29-2013 at 05:21 PM. |
![]() |
![]() |
![]() |
#11 |
Pain in the arse
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
But do you want to run the script only one time, or when you need it? If it's the second one, you can install the Tweaks hack and create an entry in kobotweaks.ini.
(My english is not better... trust me ![]() |
![]() |
![]() |
![]() |
#12 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
Only one time, the script remove himself in last instruction.
Only just after plugin has been installed. |
![]() |
![]() |
![]() |
#13 |
Pain in the arse
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
|
Ooooook, you have to check the source code of the installer of yoq's Night Mode hack.
I'm curious... do you want to silently destroy your enemy's Kobo? :-p |
![]() |
![]() |
![]() |
#14 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
If I make my plugin work, I'll explain his purpose
![]() |
![]() |
![]() |
![]() |
#15 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 93
Karma: 11824
Join Date: Feb 2013
Device: Kobo Mini/Aura H2O/Aura One LE / Tea Inkpad 3
|
So, I looked at the nightmode plugin.
I see a file /root/autorun.sh I made one for my plugin : Code:
/mnt/onboard/.kobo/MyShell.sh rm /root/autorun.sh sync reboot |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
pdf to txt shell script | Mr.Castro0o | 0 | 03-27-2013 07:39 AM | |
Shell script to wait for user input from K3g keyboard | jmseight | Kindle Developer's Corner | 33 | 04-01-2012 04:32 PM |
Bash Script/SQL Query for ISBN in filename? | zenrhino | Calibre | 1 | 09-26-2010 08:55 AM |