开发者

making multiple sqlite3 calls in a shell script

i am looking to execute the following commands within a shell script:

$ sqlite3 /Users/riceje7/bin/places.sqlite
sqlite > .output places.txt;
sqlite > SELECT url FROM moz_places;
sqlite > .quit;
$ lpr /Users/riceje7/bin/places.txt

howe开发者_运维知识库ver the script stops after the initial sqlite3 command call and only executes the other commands after i manually quit sqlite. does anyone know how i can force the script to execute these commands in this order without having to manually enter them?


You should be doing..

sqlite3 [OPTIONS] FILENAME [SQL]

so...

sqlite3 /Users/riceje7/bin/places.sqlite  "SELECT url FROM moz_places" > places.txt
lpr /Users/riceje7/bin/places.txt

Or better yet (unless you need to keep places.txt for some reason)...

sqlite3 /Users/riceje7/bin/places.sqlite  "SELECT url FROM moz_places" | lpr
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜