1. Download our Official Android App: Forums for Android!

Root velocity init d question or timing question

Discussion in 'Android Devices' started by dcooterfrog, Jun 16, 2011.

  1. dcooterfrog

    dcooterfrog Well-Known Member
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    175
    Joined:
    Dec 20, 2010

    Dec 20, 2010
    175
    9
    36
    a couiple of questions
    I have a sqlite3 script I would like to run at least at each reboot but preferable on a schedule.

    does busibox suport cron
    how do I run the script from a shell script for init d

    in terminal or abd I
    cd to the directory where the db is
    then I type

    sqlite database.db
    .read sqlscript.sql
    .end
     

    Advertisement

  2. savoxis

    savoxis Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    812
    Joined:
    Aug 10, 2010

    Aug 10, 2010
    812
    708
    163
    ODOT Field Services Tech
    Pacific NW
    If you want it on a schedule... use cron


    Code (Text):
    1. BusyBox v1.18.4darkXshadows (2011-04-28 23:05:11 CDT) multi-call binary.
    2.  
    3. Usage: crontab [-c DIR] [-u USER] [-ler]|[FILE]
    4.  
    5.     -c  Crontab directory
    6.     -u  User
    7.     -l  List crontab
    8.     -e  Edit crontab
    9.     -r  Delete crontab
    10.     FILE    Replace crontab by FILE ('-': stdin)

    I haven't even considered using crond on android, and I was a little surprised to see it there. but it is there. I use it on all my tux machines to automate updates, repo syncing, and other things. Im not sure how to get it going on android, and after spending about 25 seconds playing with it you will need some additional configuration (it just bitches at me saying it doesnt know who uid0 {root} is) But see what you can do and let me know. when I have time I may look into it. (also check market there are prolly apps that emulate what crond does)


    Or you can put your commands in a script
    Code (Text):
    1. #!/system/bin/sh
    2. db="/path/to/your/db/file"
    3. sqlscript="/path/to/your/sqlscript.sql
    4.  
    5. #open db and read the script
    6. sqlite3 -init $sqlscript $db
    7. exit 1
    8. #exit the sqlite shell (think this will be enough)
    9.  
    10. #Also note the sdcard is not mounted during init, so you may want to put
    11. #your stuff in like /etc/velocity/ or wherever on either system or data
    12.  
    13.  
    Name it like 06sqlitedbreader (or whatever the # is the execution order, do a ls /etc/init.d to see the other inits)
    chmod it 777
    and it will run at boot.

    To test the script
    run it manually in a terminal by invoking it
    sh /etc/init.d/06sqlitedbreader



    good luck im runnin out the door or I would explain more

    EDIT fixed script after reading sqlite3 --help

    Code (Text):
    1. bash-3.2# sqlite3 --help
    2. Usage: sqlite3 [OPTIONS] FILENAME [SQL]
    3. FILENAME is the name of an SQLite database. A new database is created
    4. if the file does not previously exist.
    5. OPTIONS include:
    6.    -init filename       read/process named file
    7.    -echo                print commands before execution
    8.    -[no]header          turn headers on or off
    9.    -bail                stop after hitting an error
    10.    -interactive         force interactive I/O
    11.    -batch               force batch I/O
    12.    -column              set output mode to 'column'
    13.    -csv                 set output mode to 'csv'
    14.    -html                set output mode to HTML
    15.    -line                set output mode to 'line'
    16.    -list                set output mode to 'list'
    17.    -separator 'x'       set output field separator (|)
    18.    -nullvalue 'text'    set text string for NULL values
    19.    -version             show SQLite version
     
    dcooterfrog likes this.
  3. dcooterfrog

    dcooterfrog Well-Known Member
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    175
    Joined:
    Dec 20, 2010

    Dec 20, 2010
    175
    9
    36
    I think your stuff above plus some time hacking around at will do what I want.
     
Tags:

Share This Page

Loading...