Peng Yu wrote: > On Thu, Jun 24, 2010 at 5:05 AM, Simon Slavin <slav...@bigfraud.org> wrote: > > > > On 24 Jun 2010, at 4:50am, Peng Yu wrote: > > > >> Is there a way to use Shebang for sqlite3 script? > >> > >> http://en.wikipedia.org/wiki/Shebang_%28Unix%29 > > > > SQLite comes with a command-line tool. You can feed it with individual > > commands on a Unix command-line or tell it to read commands from a file. > > I was asking whether it is possible to use Shebang with sqlite script. > If it is possible, would you please show me how to modify the > following script to do so? > > $ ./main.sql > Error: unknown command or invalid arguments: "/main.sql". Enter > ".help" for help > $ cat main.sql > #!/usr/bin/sqlite3 main.db > > create table tbl1(one varchar(10), two smallint); > .quit
You want to pretend a .sql file is an executable and send commands to sqlite3? Try something like this: [hudson:~] $ cat foo.sql #!/bin/sh sqlite3 main.db <<EOF create table tbl1(col1 text); insert into tbl1 values('foobar'); EOF [hudson:~] $ chmod +x foo.sql [hudson:~] $ ./foo.sql [hudson:~] $ lh main.db -rw-r--r--. 1 eas eas 2.0K Jun 24 10:18 main.db [hudson:~] $ sqlite3 main.db "select * from tbl1" foobar [hudson:~] $ -- Eric A. Smith Peace, n.: In international affairs, a period of cheating between two periods of fighting. -- Ambrose Bierce, "The Devil's Dictionary" _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users